folly::ManualExecutor

A ManualExecutor only does work when you turn the crank, by calling run() or indirectly with makeProgress() or waitFor().

Synopsis

Declared in <folly/executors/ManualExecutor.h>

class ManualExecutor
    : public DrivableExecutor
    , public ScheduledExecutor
    , public SequencedExecutor

Description

The clock for a manual executor starts at 0 and advances only when you ask it to. i.e. time is also under manual control.

NB No attempt has been made to make anything other than add and schedule threadsafe.

Base Classes

NameDescription
DrivableExecutorAn executor that can be driven forward via its drive() method.
ScheduledExecutorAn executor that supports timed scheduling. Like RxScheduler.
SequencedExecutorAn executor that sequences tasks whose submissions were sequenced.

Type Aliases

NameDescription
Duration The duration type used for scheduling.
KeepAlive Alias for ExecutorKeepAlive, a safe pointer to an Executor.
TimePoint The time point type used for scheduling.

Member Functions

NameDescription
~ManualExecutor [destructor] [virtual]Destroy the executor.
add add overloads
addWithPriority [virtual]Enqueue a function with a given priority, where 0 is the medium priority This is up to the implementation to enforce
advance Advance the clock. The clock never advances on its own. Advancing the clock causes some work to be done, if work is available to do (perhaps newly available because of the advanced clock). If dur is <= 0 this is a noop.
advanceTo Advance the clock to this absolute time. If t is <= now(), this is a noop.
clear Flush the function queue. Destroys all stored functions without executing them. Returns number of removed functions.
drain Do work until there is no more work to do. Returns the number of functions that were executed (maybe 0). Unlike run, this method is not stable. It will chase an infinite tail of work so should be used with care. There will be no work available to perform at the moment that this returns.
drive [virtual]Implements DrivableExecutor
getNumPriorities [virtual]Returns the number of priority levels this executor supports.
keepAliveAcquire [virtual]Acquire a keep-alive reference to this executor.
keepAliveRelease [virtual]Release a keep-alive reference to this executor.
makeProgress Wait for work to do, and do it.
now [virtual]Return the current time of the manual clock.
run Do work. Returns the number of functions that were executed (maybe 0). Non-blocking, in the sense that we don't wait for work (we can't control whether one of the functions blocks). This is stable, it will not chase an ever-increasing tail of work. This also means, there may be more work available to perform at the moment that this returns.
schedule schedule overloads
scheduleAt scheduleAt overloads
step Execute only the function at the front of the queue (maybe 0) and remove it from the queue. Non blocking where it does not wait for work if none exists Returns 1 if a function was executed and 0 otherwise
wait Wait for work to do.
waitFor makeProgress until this Future is ready.

Static Member Functions

NameDescription
getKeepAliveToken getKeepAliveToken overloads
invokeCatchingExns Invokes f, logging and swallowing any exception it throws.

Static Data Members

NameDescription
HI_PRI Highest schedulable priority.
LO_PRI Lowest schedulable priority.
MID_PRI Medium (default) schedulable priority.

Protected Member Functions

NameDescription
keepAliveAcquire [virtual]Acquire a keep alive token. Should return false if keep-alive mechanism is not supported.
keepAliveRelease [virtual]Release a keep alive token previously acquired by keepAliveAcquire(). Will never be called if keepAliveAcquire() returns false.

Protected Static Member Functions

NameDescription
isKeepAliveDummy Returns true if the KeepAlive is constructed from an executor that does not support the keep alive ref-counting functionality
keepAliveAcquire Acquires a keep-alive reference on executor.
keepAliveRelease Releases a keep-alive reference on executor.
makeKeepAlive Makes a counted (non-dummy, non-alias) keep-alive referring to executor.

Non-Member Functions

NameDescription
async_tracing::logFutureViaTrace hook invoked when a Future is rescheduled onto an executor.
async_tracing::logGetGlobalCPUExecutorTrace hook invoked when the global CPU executor is retrieved.
async_tracing::logGetImmutableCPUExecutorTrace hook invoked when the immutable CPU executor is retrieved.
async_tracing::logSemiFutureViaTrace hook invoked when a SemiFuture is rescheduled onto an executor.
async_tracing::logSetGlobalCPUExecutorTrace hook invoked when the global CPU executor is set.