Aikido
|
Combine multiple executors (i.e. More...
#include <aikido/common/ExecutorMultiplexer.hpp>
Public Member Functions | |
ExecutorMultiplexer ()=default | |
Default constructor. More... | |
~ExecutorMultiplexer ()=default | |
Default destructor. More... | |
void | addCallback (std::function< void()> callback) |
Adds a callback. More... | |
void | removeAllCallbacks () |
Removes all the added callbacks. More... | |
bool | isEmpty () const |
Returns true if no callback is added. Otherwise, returns false. More... | |
std::size_t | getNumCallbacks () const |
Returns the number of added callbacks. More... | |
void | operator() () |
Executes all the added callbacked in order of they added. More... | |
Private Attributes | |
std::mutex | mMutex |
Mutex for the list of callbacks. More... | |
std::vector< std::function< void()> > | mCallbacks |
Array of callbacks. More... | |
Combine multiple executors (i.e.
no argument callbacks) into one executor.
This helper class allows one ExecutorThread to call multiple executors by sequentially calling the callbacks added to this class.
|
default |
Default constructor.
|
default |
Default destructor.
void aikido::common::ExecutorMultiplexer::addCallback | ( | std::function< void()> | callback | ) |
Adds a callback.
The added callbacks will be called by operator().
The order of callback calling is implementation detail that is subject to change.
[in] | callback | Any callable object that doesn't return and take any parameters. |
std::size_t aikido::common::ExecutorMultiplexer::getNumCallbacks | ( | ) | const |
Returns the number of added callbacks.
bool aikido::common::ExecutorMultiplexer::isEmpty | ( | ) | const |
Returns true if no callback is added. Otherwise, returns false.
void aikido::common::ExecutorMultiplexer::operator() | ( | ) |
Executes all the added callbacked in order of they added.
void aikido::common::ExecutorMultiplexer::removeAllCallbacks | ( | ) |
Removes all the added callbacks.
|
private |
Array of callbacks.
|
mutableprivate |
Mutex for the list of callbacks.
The array of callbacks will be locked during it's modified and the callbacks are called.