Kallisto Linux API
Library for interacting with Kallisto devices
|
#include <executor.hpp>
Public Types | |
typedef std::function< void()> | ExecutorRunnable |
Public Member Functions | |
Executor (std::string tag, unsigned int nr_threads) | |
~Executor () | |
error::KallistoDetailedResult | execute (ExecutorRunnable runnable) |
error::KallistoDetailedResult | shutdown () |
error::KallistoDetailedResult | shutdownNow () |
void | awaitShutdown () |
Static Public Attributes | |
static const unsigned int | MAXIMUM_NUMBER_THREADS |
static const unsigned int | MINIMUM_NUMBER_THREADS |
Class used to schedule ExecutorRunnable to a queue to be run in a background thread. A ExecutorRunnable is a simple std::function<void()> that can be used to run anything needed:
Executor executor("myExecutor", 1);executor.execute([=](){doSomething();});...
If only one thread is specified, each runnable will be executed sequentially.
typedef std::function<void()> ExecutorRunnable |
Declaration of the function to be executed by the Executor.
Executor | ( | std::string | tag, |
unsigned int | nr_threads | ||
) |
Constructor.
tag | Tag used in logging messages. |
nr_threads | Number of concurrent threads. If the value is > Executor::MAXIMUM_NUMBER_OF_THREADS or < Executor::MINIMUM_NUMBER_OF_THREADS it will be truncated. |
~Executor | ( | ) |
Destructor.
void awaitShutdown | ( | ) |
Waits for this executor threads termination. Beware that this function does not shutdown the executor.
error::KallistoDetailedResult execute | ( | ExecutorRunnable | runnable | ) |
Schedules a new runnable to be executed by the Executor.
runnable | The function to be executed. |
error::KallistoDetailedResult shutdown | ( | ) |
Signal threads to finish the runnables in the the backlog and to exit. After this call, no new runnables can be scheduled. This function does not wait for thread termination. Use awaitShutdown() for that.
error::KallistoDetailedResult shutdownNow | ( | ) |
Signal threads to exit ASAP. After this call, no new runnables can be scheduled. This function does not wait for thread termination. Use awaitShutdown() for that.
|
static |
Maximum number of threads allowed.
|
static |
Minimum number of threads allowed.