23 #include "aqt_vision_threads.h" 25 #include <core/threading/barrier.h> 26 #include <utils/time/clock.h> 27 #include <aspect/vision.h> 49 _empty_time =
new Time();
56 cyclic_barrier =
new Barrier(1);
64 delete cyclic_barrier;
66 delete running_threads_cyclic;
67 delete running_threads_cont;
68 delete waiting_threads;
81 waiting_threads->push_back_locked(thread);
92 if ( find(waiting_threads->begin(), waiting_threads->end(), thread) != waiting_threads->end()) {
94 running_threads_cyclic->push_back_locked(thread);
95 delete cyclic_barrier;
96 cyclic_barrier =
new Barrier( running_threads_cyclic->size() + 1 );
98 running_threads_cont->push_back_locked(thread);
100 waiting_threads->remove_locked(thread);
112 waiting_threads->remove_locked(thread);
113 if ( find(running_threads_cyclic->begin(), running_threads_cyclic->end(), thread) !=
114 running_threads_cyclic->end()) {
116 running_threads_cyclic->remove_locked(thread);
118 delete cyclic_barrier;
119 cyclic_barrier =
new Barrier( running_threads_cyclic->size() + 1 );
121 running_threads_cont->remove_locked(thread);
134 waiting_threads->remove_locked(thread);
147 return ( ! running_threads_cyclic->empty() );
157 return ( ! running_threads_cont->empty() );
168 return (find(waiting_threads->begin(), waiting_threads->end(), t) != waiting_threads->end());
179 return ( waiting_threads->empty() &&
180 running_threads_cyclic->empty() &&
181 running_threads_cont->empty() );
191 return clock->
elapsed(_empty_time);
199 if ( has_cyclic_thread() ) {
200 running_threads_cyclic->wakeup(cyclic_barrier);
201 cyclic_barrier->wait();
218 running_threads_cyclic->set_prepfin_hold(hold);
220 running_threads_cyclic->set_prepfin_hold(
false);
void wakeup_and_wait_cyclic_threads()
Wakeup and wait for all cyclic threads.
bool has_cont_thread()
Check if there is at least one continuous thread.
Fawkes library namespace.
void get_systime(struct timeval *tv) const
Returns the system time.
This is supposed to be the central clock in Fawkes.
float elapsed(Time *t) const
How much time has elapsed since t? Calculated as "now - t" in seconds.
bool has_waiting_thread(fawkes::Thread *t)
Check if the given waiting thread is registered.
FvAqtVisionThreads(fawkes::Clock *clock)
Constructor.
A class for handling time.
~FvAqtVisionThreads()
Destructor.
Thread class encapsulation of pthreads.
void set_prepfin_hold(bool hold)
Set prepfin hold fo cyclic threads.
void set_thread_running(fawkes::Thread *thread)
Mark the thread as running.
void remove_waiting_thread(fawkes::Thread *thread)
Remove waiting thread.
bool has_cyclic_thread()
Check if there is at least one cyclic thread.
bool empty()
Check if there is no thread at all.
Base class for exceptions in Fawkes.
Thread aspect to use in FireVision apps.
VisionThreadMode vision_thread_mode()
Get the vision thread mode of this thread.
void remove_thread(fawkes::Thread *thread)
Remove a thread.
float empty_time()
Get the empty time.
void add_waiting_thread(fawkes::Thread *thread)
Add a thread in waiting state.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...