* ThreadedExecutor
Synopsis
Declared in <folly/executors/ThreadedExecutor.h>
class ThreadedExecutor
: public virtual folly::Executor
Description
An executor for blocking tasks.
This executor runs each task in its own thread. It works well for tasks which mostly sleep, but works poorly for tasks which mostly compute.
For each task given to the executor with add, the executor spawns a new thread for that task, runs the task in that thread, and joins the thread after the task has completed.
Spawning and joining task threads are done in the executor's internal control thread. Calls to add put the tasks to be run into a queue, where the control thread will find them.
There is currently no limitation on, or throttling of, concurrency.
This executor is not currently optimized for performance. For example, it makes no attempt to re‐use task threads. Rather, it exists primarily to offload sleep‐heavy tasks from the CPU executor, where they might otherwise be run.
Base Classes
Name |
Description |
Schedules and runs asynchronous work. |
Type Aliases
Name |
Description |
Alias for ExecutorKeepAlive, a safe pointer to an Executor. |
Member Functions
Name |
Description |
|
Constructors |
|
Stops the control thread and joins any remaining task threads. |
Assignment operators |
|
|
Enqueues a task to be run in its own thread. |
|
Enqueue a function with a given priority, where 0 is the medium priority This is up to the implementation to enforce |
|
Returns the number of priority levels this executor supports. |
Static Member Functions
Name |
Description |
|
|
Invokes |
Static Data Members
Name |
Description |
Highest schedulable priority. |
|
Lowest schedulable priority. |
|
Medium (default) schedulable priority. |
Protected Member Functions
Name |
Description |
|
Acquire a keep alive token. Should return false if keep‐alive mechanism is not supported. |
|
Release a keep alive token previously acquired by keepAliveAcquire(). Will never be called if keepAliveAcquire() returns false. |
Protected Static Member Functions
Name |
Description |
Returns true if the KeepAlive is constructed from an executor that does not support the keep alive ref‐counting functionality |
|
Acquires a keep‐alive reference on |
|
Releases a keep‐alive reference on |
|
Makes a counted (non‐dummy, non‐alias) keep‐alive referring to |
Non-Member Functions
Name |
Description |
Trace hook invoked when a Future is rescheduled onto an executor. |
|
Trace hook invoked when the global CPU executor is retrieved. |
|
|
Trace hook invoked when the immutable CPU executor is retrieved. |
Trace hook invoked when a SemiFuture is rescheduled onto an executor. |
|
Trace hook invoked when the global CPU executor is set. |
Created with MrDocs