folly::getGlobalCPUExecutorWeakRef

methodset Executors

Synopsis

Declared in <folly/executors/GlobalExecutor.h>

folly::Executor::KeepAlive<>
getGlobalCPUExecutorWeakRef();

Description

Same as getGlobalCPUExecutor(), but returns a weak keepalive: holding this keepalive will not keep the global executor alive at shutdown, and tasks scheduled on it during or after shutdown will not be executed. This can be used for best-effort tasks, but it should not be used for future or coroutine continuations, as they expect a guarantee of forward progress and can deadlock if progress is not guaranteed.

Retrieve the global immutable executor. This executor is a CPU thread pool of appropriate machine core size.

Use to run CPU workloads.

Return Value

KeepAlive wrapped global immutable CPU executor. May throw on shutdown. If no throw, returned KeepAlive is valid.