Lightweight cooperative userspace threads (fibers) and related primitives.

Namespaces

Name

Description

async

Async/await‐style API for running fiber tasks.

Types

Name

Description

ABDCommitNotCalledException

An exception class that gets set on the promise for dispatched tokens, when the AtomicBatchDispatcher was destroyed before commit was called on it.

ABDTokenNotDispatchedException

An exception class that gets set on the promise for dispatched tokens, when one or more other tokens in the batch were destroyed before dispatch was called on them. Only here so that the caller can distinguish the real failure cause rather than these subsequently thrown exceptions.

ABDUsageException

An exception class that gets thrown when the AtomicBatchDispatcher is used incorrectly. This is indicative of a bug in the user code. Examples are, multiple dispatch calls on the same token, trying to get more tokens from the dispatcher after commit has been called, etc.

AtomicBatchDispatcher

AtomicBatchDispatcher should be used if you want to process fiber tasks in parallel, but require to synchronize them at some point. The canonical example is to create a database transaction dispatch round. This API notably enforces that all tasks in the batch have reached the synchronization point before the user provided dispatch function is called with all the inputs provided in one function call. It also provides a guarantee that the inputs in the vector of inputs passed to the user provided dispatch function will be in the same order as the order in which the token for the job was issued.

BatchDispatcher

BatchDispatcher is useful for batching values while doing I/O. For example, if you are launching multiple tasks which take a single id and each task fetches from database, you can use BatchDispatcher to batch those ids and do a single query requesting all those ids.

BatchSemaphore

Fiber‐compatible batch semaphore with ability to perform batch token increment/decrement. Will safely block fibers that wait when no tokens are available and wake fibers when signalled.

Baton

Primitive which allows one to put current Fiber to sleep and wake it from another Fiber/thread.

EventBaseLoopController

A LoopController that drives a FiberManager loop from a folly EventBase.

ExecutorBasedLoopController

Interface for LoopController with publicly acessible executor

ExecutorLoopController

A fiber loop controller that works for arbitrary folly::Executor

ExecutorTimeoutManager

A TimeoutManager that schedules timeouts on a folly::Executor.

Fiber

Fiber object used by FiberManager to execute tasks.

FiberImpl

Low‐level fiber wrapper over Boost.Context that switches execution contexts.

FiberManager

Single‐threaded task execution engine.

FirstArgOf

Trait that yields the type of the first argument of a callable F.

GuardPageAllocator

Stack allocator that protects an extra memory page after the end of the stack. Will only add extra memory pages up to a certain number of allocations to avoid creating too many memory maps for the process.

LoopController

Interface driving the loop that runs a FiberManager's ready fibers.

Semaphore

Fiber‐compatible semaphore. Will safely block fibers that wait when no tokens are available and wake fibers when signalled.

SemaphoreBase

Fiber‐compatible semaphore base. Will safely block fibers that wait when no tokens are available and wake fibers when signalled.

SimpleLoopController

A LoopController that drives a FiberManager loop inline, mainly for tests.

StackCacheEntry

Caches fiber stacks with guard pages for reuse across allocations.

TaskIterator

Traverses tasks scheduled by addTasks in the order they complete.

TaskOptions

Options controlling how a fiber task is executed.

TimedMutex

Like mutex but allows timed_lock in addition to lock and try_lock.

TimedRWMutexImpl

A readers‐writer lock which allows multiple readers to hold the lock simultaneously or only one writer.

Type Aliases

Name

Description

GenericBaton

Alias for the fiber‐compatible Baton synchronization primitive.

TimedRWMutex

A timed readers‐writer mutex, defaulting to reader priority.

TimedRWMutexReadPriority

A reader‐preferred timed readers‐writer mutex.

TimedRWMutexWritePriority

A writer‐preferred timed readers‐writer mutex.

once_flag

Fiber‐compatible once flag backed by a TimedMutex.

Functions

Name

Description

addTasks

addTasks overloads

collectAll

collectAll overloads

collectAny

collectAny overloads

collectN

collectN overloads

createAtomicBatchDispatcher

Creates an AtomicBatchDispatcher that uses the given dispatch function.

forEach

Schedules several tasks and blocks until all of them are completed. In the process of their successful completion given callback would be called for each of them with the index of the task and the result it returned (if not void). If any of these n tasks throws an exception, this exception will be re‐thrown, but only when all tasks are complete. If several tasks throw exceptions one of them will be re‐thrown. Callback won't be called for tasks that throw exception.

getFiberManagerT

Returns the fiber manager keyed by the local type Local for evb.

installGuardPageSignalHandler

Unconditionally install the SIGSEGV handler that detects fiber stack overflow. Can be useful if the handler has been overridden by some other code overriding the SIGSEGV handler

Created with MrDocs