folly::VirtualExecutor

VirtualExecutor implements a light-weight view onto existing Executor.

Synopsis

Declared in <folly/executors/VirtualExecutor.h>

class VirtualExecutor
    : public DefaultKeepAliveExecutor

Description

Multiple VirtualExecutors can be backed by a single Executor.

VirtualExecutor's destructor blocks until all tasks scheduled through it are complete. Executor's destructor also blocks until all VirtualExecutors backed by it are released.

Base Classes

NameDescription
DefaultKeepAliveExecutorAn Executor accepts units of work with add(), which should be threadsafe.

Types

NameDescription
WeakRefExecutor Marker base for the weak-reference executor wrappers.

Type Aliases

NameDescription
KeepAlive Alias for ExecutorKeepAlive, a safe pointer to an Executor.

Member Functions

NameDescription
VirtualExecutor [constructor]Constructors
~VirtualExecutor [destructor] [virtual]Destroys the executor, blocking until all scheduled tasks complete.
operator= [deleted]Copy assignment operator (deleted).
add add overloads
addWithPriority addWithPriority overloads
getNumPriorities [virtual]Returns the number of priority levels supported by the backing executor.
weakRef Returns a weak keep-alive to this executor.

Static Member Functions

NameDescription
getKeepAliveToken getKeepAliveToken overloads
getWeakRef Returns a weak keep-alive to executor that does not extend its lifetime.
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
joinAndResetKeepAlive Joins the keep-alive, then reinstates a fresh one so the executor is reusable.
joinKeepAlive Releases this executor's own keep-alive and waits for all others to drain.
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.