Open Lighting Architecture
0.10.4
|
Enables callbacks to be executed in a separate thread.
callback | the callback to run. |
This can be used to deferred deletion of objects. e.g.
Public Member Functions | |
ExecutorThread (const ola::thread::Thread::Options &options) | |
Create a new ExecutorThread. More... | |
void | Execute (ola::BaseCallback0< void > *callback) |
Execute the supplied callback at some point in the future. More... | |
void | DrainCallbacks () |
Block until all pending callbacks have been processed. More... | |
bool | Start () |
Start the ExecutorThread. More... | |
bool | Stop () |
Stop this Executor thread. More... | |
|
inlineexplicit |
Create a new ExecutorThread.
options | The thread options to use |
|
virtual |
Block until all pending callbacks have been processed.
The callbacks continue to be run in the ExecutorThread, so if the thread has been stopped this will block indefinitely.
Implements ola::thread::ExecutorInterface.
|
virtual |
Execute the supplied callback at some point in the future.
callback | the callback to run. |
This method provides the following guarantees:
When queuing callbacks, you ether need to ensure that either:
To achieve the latter it's common to keep track of the number of outstanding callbacks and then call DrainCallbacks() in the destructor if the number of outstanding callbacks is non-0.
Implements ola::thread::ExecutorInterface.
bool ola::thread::ExecutorThread::Start | ( | ) |
Start the ExecutorThread.
Not thread safe, should only be called once.
bool ola::thread::ExecutorThread::Stop | ( | ) |