Valkka
1.6.1
OpenSource Video Management
|
Go to the documentation of this file. 1 #ifndef THREADS_HEADER_GUARD
2 #define THREADS_HEADER_GUARD
135 std::thread internal_thread;
139 pthread_t internal_thread;
144 virtual void run() = 0;
146 virtual void preRun() = 0;
163 static void *mainRun_(
void *p);
void closeThread()
Sends exit signal to the thread, calls join. This method blocks until thread has exited....
Definition: thread.cpp:91
FrameFifo * framefifo
Consume frames from here.
Definition: thread.h:234
void run()
Main execution loop is defined here.
Definition: thread.cpp:250
std::mutex loop_mutex
Protects thread's main execution loop (if necessary)
Definition: thread.h:127
virtual void waitReady()
Wait until thread has processed all its signals.
Definition: thread.cpp:234
virtual void run()=0
Main execution loop is defined here.
void startCall()
API method: starts the thread.
Definition: thread.cpp:134
void preRun()
Called before entering the main execution loop, but after creating the thread.
Definition: thread.cpp:248
std::condition_variable start_condition
Notified when the thread has been started.
Definition: thread.h:122
virtual void postRun()=0
Called after the main execution loop exits, but before joining the thread.
virtual void stopCall()
API method: stops the thread.
Definition: thread.cpp:184
void setAffinity(int i)
API method for setting the thread affinity.
Definition: thread.cpp:58
Thread safe system of fifo and a stack.
std::mutex start_mutex
Mutex protecting start_condition.
Definition: thread.h:121
std::condition_variable condition
Condition variable for the signal queue (triggered when all signals processed). Not necessarily used ...
Definition: thread.h:125
A demo thread for testing the producer/consumer module for fifos.
Definition: thread.h:198
void run()
Main execution loop is defined here.
Definition: thread.cpp:271
Signal
List of possible signals for the thread.
Definition: thread.h:59
A thread-safe combination of a fifo (first-in-first-out) queue and an associated stack.
Definition: framefifo.h:83
~Thread()
Destructor:not virtual.
Definition: thread.cpp:45
Encapsulates data sent by the signal.
Definition: thread.h:73
virtual void preRun()=0
Called before entering the main execution loop, but after creating the thread.
std::string name
Name of the thread.
Definition: thread.h:116
A demo thread for testing the producer/consumer module for fifos.
Definition: thread.h:222
virtual void preJoin()
Called before the thread is joined.
Definition: thread.cpp:126
virtual void sendSignalAndWait(SignalContext signal_ctx)
Send a signal to the thread and wait for all signals to be executed.
Definition: thread.cpp:225
pthread_attr_t thread_attr
Thread attributes, pthread_* way.
Definition: thread.h:137
@ none
undefined (initial value)
Definition: usbthread.h:143
bool loop
Use this boolean to control if the main loop in Thread:run should exit.
Definition: thread.h:130
std::mutex mutex
Mutex protecting the condition variable and signal queue.
Definition: thread.h:124
void operator=(const Thread &)
Void copy-constructor: this class is non-copyable.
virtual void waitStopCall()
API method: waits until the thread is joined.
Definition: thread.cpp:213
void preRun()
Called before entering the main execution loop, but after creating the thread.
Definition: thread.cpp:269
Thread(const char *name)
Default constructor.
Definition: thread.cpp:41
An example of information context sent to the Thread inside Thread::SignalContext.
Definition: thread.h:48
void postRun()
Called after the main execution loop exits, but before joining the thread.
Definition: thread.cpp:249
virtual void postJoin()
Called after the thread has been joined.
Definition: thread.cpp:129
virtual void sendSignal(SignalContext signal_ctx)
Send a signal to the thread.
Definition: thread.cpp:218
FrameFifo * framefifo
Feed frames here.
Definition: thread.h:210
void postRun()
Called after the main execution loop exits, but before joining the thread.
Definition: thread.cpp:270
void mainRun()
Does the preRun, run, postRun sequence.
Definition: thread.cpp:68
A class for multithreading with a signaling system.
Definition: thread.h:87
std::deque< SignalContext > signal_fifo
Signal queue (fifo). Redefine in child classes.
Definition: thread.h:129
virtual void requestStopCall()
API method: stops the thread.
Definition: thread.cpp:200
bool has_thread
true if thread has been started
Definition: thread.h:117