ExecutorKeepAlive is a safe pointer to an Executor.

Synopsis

Declared in <folly/Executor.h>

template<typename ExecutorT = Executor>
class ExecutorKeepAlive;

Description

For any Executor that supports keep‐alive functionality, its destructor will block until all the ExecutorKeepAlive objects associated with that executor are destroyed. For executors that don't support the keep‐alive functionality, ExecutorKeepAlive doesn't provide such protection.

ExecutorKeepAlive should always be used instead of Executor*. ExecutorKeepAlive can be implicitly constructed from Executor*.

The getKeepAliveToken() helper can be used to construct a keep‐alive in templated code if you need to preserve the original executor type.

Type Aliases

Name

Description

KeepAliveFunc

A callable that consumes an rvalue keep‐alive to this executor.

Member Functions

Name

Description

ExecutorKeepAlive [constructor]

Constructors

~ExecutorKeepAlive [destructor]

Releases the referenced executor keep‐alive, if any.

operator=

Assignment operators

add

Enqueues f on the referenced executor, passing it this consumed token.

copy

Returns a new keep‐alive that shares this token's executor.

get

Returns the referenced executor, or nullptr if empty.

get_alias

Returns an alias keep‐alive whose lifetime is assumed to be surrounded by this one.

operator*

Returns a reference to the referenced executor.

operator‐>

Returns a pointer to the referenced executor.

reset

Releases the referenced executor keep‐alive and empties this token.

operator bool

Returns true if this token refers to an executor.

Friends

Name

Description

folly::ExecutorKeepAlive

ExecutorKeepAlive is a safe pointer to an Executor.

folly::Executor

Schedules and runs asynchronous work.

Non-Member Functions

Name

Description

co_viaIfAsync

co_viaIfAsync

co_viaIfAsync

Created with MrDocs