Open Lighting Architecture
0.9.5
|
Defer execution of a callback.
The executor interface provides a method to defer execution of a callback. Often we want to break the call stack, say if we need to run a callback that modify / delete a non-reentrant object in our call stack.
Public Member Functions | |
virtual void | Execute (ola::BaseCallback0< void > *callback)=0 |
Execute the supplied callback at some point in the future. | |
virtual void | DrainCallbacks ()=0 |
Run all callbacks until there are none left. |
|
pure 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.
Implemented in ola::io::SelectServer, ola::PluginAdaptor, and ola::thread::ExecutorThread.