|
MarlinMT
0.1.0
|
#include <ThreadPool.h>
Public Types | |
| using | Input = IN |
| using | Output = OUT |
| using | Pool = ThreadPool< IN, OUT > |
| using | Impl = WorkerBase< IN, OUT > |
Public Member Functions | |
| Worker ()=delete | |
| Worker (const Worker &)=delete | |
| Worker (Worker &&)=delete | |
| Worker & | operator= (const Worker &)=delete |
| Worker & | operator= (Worker &&)=delete |
| template<typename IMPL , class = typename std::enable_if<std::is_base_of<Impl,IMPL>::value>::type> | |
| Worker (Pool &pool, std::unique_ptr< IMPL > impl) | |
| Constructor. More... | |
| void | start () |
| Start the worker thread. More... | |
| void | run () |
| The method executing in the worker thread. More... | |
| void | stop () |
| Switch ON the stop flag, requesting the worker thread to stop. More... | |
| bool | running () const |
| Whether the worker thread is currently running. More... | |
| bool | waiting () const |
| Whether the worker is waiting. More... | |
| void | join () |
| Join the worker thread. More... | |
Private Attributes | |
| Pool & | _threadPool |
| < The parent thread pool More... | |
| std::thread | _thread {} |
| The stop flag. More... | |
| std::atomic< bool > | _stopFlag {false} |
| Whether the worker thread is waiting for data. More... | |
| std::atomic< bool > | _waitingFlag {false} |
| The worker implementation. More... | |
| std::unique_ptr< Impl > | _impl {nullptr} |
Worker class.
Definition at line 25 of file ThreadPool.h.
| using marlinmt::concurrency::Worker< IN, OUT >::Impl = WorkerBase<IN,OUT> |
| using marlinmt::concurrency::Worker< IN, OUT >::Input = IN |
| using marlinmt::concurrency::Worker< IN, OUT >::Output = OUT |
| using marlinmt::concurrency::Worker< IN, OUT >::Pool = ThreadPool<IN, OUT> |
|
delete |
|
delete |
|
delete |
|
inline |
|
inline |
Join the worker thread.
Definition at line 278 of file Worker.h.
References marlinmt::concurrency::Worker< IN, OUT >::_thread.
|
delete |
|
delete |
|
inline |
The method executing in the worker thread.
Definition at line 226 of file Worker.h.
References marlinmt::concurrency::ThreadPool< IN, OUT >::_conditionVariable, marlinmt::concurrency::Worker< IN, OUT >::_impl, marlinmt::concurrency::ThreadPool< IN, OUT >::_isDone, marlinmt::concurrency::ThreadPool< IN, OUT >::_mutex, marlinmt::concurrency::ThreadPool< IN, OUT >::_queue, marlinmt::concurrency::Worker< IN, OUT >::_stopFlag, marlinmt::concurrency::Worker< IN, OUT >::_threadPool, marlinmt::concurrency::Worker< IN, OUT >::_waitingFlag, and marlinmt::concurrency::Queue< T, class >::pop().
Referenced by marlinmt::concurrency::Worker< IN, OUT >::start().
|
inline |
Whether the worker thread is currently running.
Definition at line 264 of file Worker.h.
References marlinmt::concurrency::Worker< IN, OUT >::_thread.
|
inline |
Start the worker thread.
Definition at line 219 of file Worker.h.
References marlinmt::concurrency::Worker< IN, OUT >::_thread, and marlinmt::concurrency::Worker< IN, OUT >::run().
|
inline |
Switch ON the stop flag, requesting the worker thread to stop.
No join operation is done here. See join() method
Definition at line 257 of file Worker.h.
References marlinmt::concurrency::Worker< IN, OUT >::_stopFlag.
|
inline |
Whether the worker is waiting.
Definition at line 271 of file Worker.h.
References marlinmt::concurrency::Worker< IN, OUT >::_waitingFlag.
|
private |
Definition at line 194 of file Worker.h.
Referenced by marlinmt::concurrency::Worker< IN, OUT >::run().
|
private |
Whether the worker thread is waiting for data.
Definition at line 190 of file Worker.h.
Referenced by marlinmt::concurrency::Worker< IN, OUT >::run(), and marlinmt::concurrency::Worker< IN, OUT >::stop().
|
private |
The stop flag.
Definition at line 188 of file Worker.h.
Referenced by marlinmt::concurrency::Worker< IN, OUT >::join(), marlinmt::concurrency::Worker< IN, OUT >::running(), and marlinmt::concurrency::Worker< IN, OUT >::start().
|
private |
< The parent thread pool
The worker thread
Definition at line 186 of file Worker.h.
Referenced by marlinmt::concurrency::Worker< IN, OUT >::run().
|
private |
The worker implementation.
Definition at line 192 of file Worker.h.
Referenced by marlinmt::concurrency::Worker< IN, OUT >::run(), and marlinmt::concurrency::Worker< IN, OUT >::waiting().