![]() |
Open Lighting Architecture 0.10.9
|
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. | |
| void | Execute (ola::BaseCallback0< void > *callback) |
| Execute the supplied callback at some point in the future. | |
| void | DrainCallbacks () |
| Block until all pending callbacks have been processed. | |
| bool | Start () |
| Start the ExecutorThread. | |
| bool | Stop () |
| Stop this Executor thread. | |
|
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 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 | ( | ) |