Coroutine primitives and combinators.
Namespaces
Name |
Description |
Tools for library authors who are building new |
Namespace Aliases
Name |
Description |
Alias for the standard namespace providing coroutine support. |
Types
Name |
Description |
The AsyncGenerator class represents a sequence of asynchronously produced values where the values are produced by a coroutine. |
|
Base class for objects whose lifetime is managed by an |
|
Owning pointer to an |
|
Tag type identifying an async object owned by an |
|
An AsyncGenerator with a write end |
|
Starts and later joins a dynamic, unbounded set of concurrent tasks. |
|
An |
|
Awaitable that yields the current async stack trace. |
|
The user can use AutoCleanup to wrap arguments passed to a CleanableAsyncGenerator. When the coroutine promise of CleanableAsyncGenerator is created it will automatically attach co_scope_exit task that performs async cleanup for all the arguments wrapped in AutoCleanup. This allows to ensure cleanup of the arguments even when next() of the CleanableAsyncGenerator is never co_awaited. |
|
A task that runs detached in the background; forward‐declared here. |
|
A baton is a synchronisation primitive for coroutines that allows a coroutine to co_await the baton and suspend until the baton is posted by some thread via a call to .post(). |
|
Bounded variant of AsyncPipe which buffers a fixed number of writes before blocking new attempts to write until the buffer is drained. |
|
A coroutine version of bounded queue with given capacity. Both enqueue and dequeue are async awaitable. |
|
A cancellable version of AsyncScope. Work added to this scope will be provided a cancellation token for cancelling during join. |
|
Handles the connect operation for an AsyncSocketTransport. |
|
Extended |
|
CRTP base letting a promise expose a more efficient error‐resumption path. |
|
The awaitable read side of a promise/future contract. |
|
A synchronous coroutine generator that lazily yields a sequence of values. |
|
A mutex that can be locked asynchronously using 'co_await'. |
|
A Rust‐style pollable adaptor over a |
|
A Rust‐style pollable adaptor over an |
|
The write side of a promise/future contract used to fulfill a Future. |
|
Handles data reads for an AsyncTransport. |
|
SerialQueueRunner |
|
A coroutine server socket that accepts connections on the same event base as the underlying socket itself. |
|
This type mirrors the interface of std::shared_lock as much as possible. |
|
The folly::coro::SharedMutexFair class provides a thread synchronisation primitive that allows a coroutine to asynchronously acquire a lock on the mutex. |
|
SharedPromise is a simple wrapper around folly::coro::Promise and folly::coro::Future that allows for fetching cancellable and awaitable futures from a single promise. |
|
Low‐memory unbounded multi‐producer/consumer queue with lower throughput. |
|
Async‐stack‐aware awaitable that reschedules onto an executor. |
|
Async‐stack‐aware awaiter that reschedules its inner awaiter onto an executor. |
|
This class is an adaptation of the folly::Synchronized class but is designed to work with coro‐compatible mutexes like coro::SharedMutexFair instead. |
|
Represents an allocated, but not‐started coroutine, which is not yet been bound to an executor. |
|
Represents an allocated but not yet started coroutine that has already been bound to an executor. |
|
CRTP base implementing the shared behavior of task‐with‐executor wrappers. |
|
CRTP base implementing the shared behavior of task wrappers. |
|
Coroutine transport backed by an AsyncTransport socket. |
|
Common base for all transport callbacks. |
|
Abstract interface for a coroutine‐based socket transport. |
|
Wrapper around folly::UnboundedQueue that supports async dequeue. |
|
An upgradable lock guard held over a coroutine‐aware mutex. |
|
Awaitable that reschedules its inner awaitable onto an executor. |
|
Awaiter that reschedules its inner awaiter onto an executor. |
|
Handles data writes for an AsyncTransport. |
|
Capture wrapper marked |
|
Capture wrapper marked |
|
Heap‐backed |
|
Pointer‐holding |
|
Learn more about |
|
Tag type used by |
|
Metafunction yielding the result type of co_awaiting an Awaitable. |
|
awaiter_type<Awaitable> |
|
Lifetime‐safe wrapper owning a captured value or reference for coroutines. |
|
Lifetime‐safe wrapper owning a captured value or reference for coroutines. |
|
Heap‐backed |
|
Capture over a pointer, adding sugar so |
|
Capture of a cleanup arg, whose refs downgrade dependents to after‐cleanup. |
|
Capture of a cleanup arg, whose refs downgrade dependents to after‐cleanup. |
|
A customization point that allows to provide an async cleanup function for a type. folly::coro::AutoCleanup uses co_cleanup_fn as the default cleanup function, so it is enough to define co_cleanup for a type to be able to use it with AutoCleanup. |
|
Wraps an exception to be thrown from a coroutine via |
|
Function object that invokes a callable and awaits its coroutine result. |
|
Wraps a Try or result to be yielded from a coroutine as its completion. |
|
Wraps a Try or result to be yielded from a coroutine as its completion. |
|
A semi‐awaitable type which, when awaited in an async coroutine supporting safe‐points, causes a safe‐point to be reached. |
|
Tag type that converts to a |
|
Trait detecting whether |
|
is_awaitable<T>::value is_awaitable_v<T> |
|
is_awaiter<T>::value is_awaiter_v<T> |
|
Trait detecting whether T is a semi‐awaitable. |
|
An immovable |
|
The executor‐bound, immovable counterpart of |
|
Primary policy struct: specify behavior for stopped (cancellation) and error. Use via the variable templates below, not directly. |
|
An awaitable that is immediately ready and yields a stored value on resume. |
|
A type trait to unwrap a std::reference_wrapper<T> to a type T |
|
Restricted view on a |
|
Restricted view on a |
|
Proxy granting safe access to an async scope's context. |
|
Why is |
|
A |
|
|
|
An awaitable backed by one of several possible underlying awaitables. |
|
Tag for "terminate on this completion". |
Type Aliases
Name |
Description |
An AsyncGenerator that requires cleanup() to be called before destruction. |
|
Backwards‐compatibility alias for |
|
Backwards‐compatibility alias for |
|
The default SharedMutex is SharedMutexFair. |
|
Coros declared as |
|
Alias for the result type of co_awaiting an Awaitable. |
|
await_result<Awaitable> |
|
Given a cvref‐qualified |
|
A |
|
A |
|
Placeholder type awaited to obtain the current coroutine's cancellation token. |
|
Placeholder type awaited to obtain the current coroutine's executor. |
|
|
Placeholder type awaited to reschedule the current coroutine onto its executor. |
A |
|
Alias for the unwrapped type of remove_reference_wrapper. |
|
The result type of co_awaiting a semi‐awaitable T. |
|
The result type of co_awaiting the Try wrapper of a semi‐awaitable T. |
|
True for awaitables that only complete with value (not stopped or error) |
|
A |
Functions
Name |
Description |
|
|
Creates a lifetime‐safe async closure task from bound args and a coroutine. |
|
|
|
Creates an immediately‐awaited async closure returning a |
|
|
|
|
|
Cheaply propagate exceptions from |
|
Creates a scope‐exit coroutine running |
|
Async version of the folly::transition_lock TODO: add more transition policies beyond just from upgrade to exclusive |
|
|
|
|
|
|
|
Concurrently await multiple awaitables and complete with a tuple of results. |
|
|
|
Concurrently await multiple awaitables and complete with a tuple of Try results. |
|
|
|
|
|
|
|
Concurrently await awaitables and complete with the first result and index. |
|
Concurrently await awaitables and return every result once one finishes. |
|
|
|
|
|
Concurrently await awaitables, returning the first success or last error. |
|
|
|
Concatenate the values from multiple streams into a single stream such that each stream is exhausted before the next one begins. |
|
detachOnCancel is used to handle operations that are hard to be cancelled. A typical use case is: The caller starts a task with timeout (in this case, 1 sec timeout). The task itself launches a long running job and the job doesn't handle cancellation (sleep_for in this example). The caller has timeout and the cancellation is propagated to the task. The detachOnCancel detects the cancellation and return immediately. However, the background task still runs until the thread join. |
|
|
Returns whether the compiler converts a coroutine promise return object eagerly. |
Filters a stream, yielding only values that satisfy the predicate. |
|
|
|
Make a Task that will trivially yield an Exception. |
|
|
|
makePromiseContract can help you migrating your non‐coroutine code base to coroutine. If your code already uses Future/SemiFuture, you don't need this tool. A common use case is with async callback functions. In the example, we can pass a callback function into the legacy code sleepAndNotify and sleepAndNotify sets the promise on completion. Consider to use detachOnCancel with this makePromiseContract to handle long running (longer than your timeout) tasks that don't handle cancellation properly. |
|
Make a Task out of a Try. |
|
|
|
|
|
|
|
Make a |
|
|
|
Merges a stream of input streams into a single interleaved output stream. |
|
|
|
Execute a given asynchronous operation returned by func(), retrying it on failure, if desired, after awaiting retryDelay(error). |
|
|
|
Schedules async cleanup for any AutoCleanup arguments on the coroutine. |
|
Return a task that, when awaited, will sleep for the specified duration. |
|
Return a task that, when awaited, will sleep for the specified duration. |
|
Swaps the state of two generators. |
|
|
|
Awaits |
|
Returns a Task that, when started, starts a timer of duration 'timeoutDuration' and awaits the passed SemiAwaitable. |
|
Returns a Task that, when started, starts a timer of duration 'timeoutDuration' and awaits the passed SemiAwaitable (operation). |
|
Converts the given SemiAwaitable to a Future, starting it on the Executor. |
|
Converts the given SemiAwaitable to a SemiFuture (without starting it). |
|
|
|
|
|
|
|
When awaited, returns a |
|
When awaited, returns |
Variables
Name |
Description |
|
Deprecated alias for |
Awaitable yielding the current async stack trace when co_awaited. |
|
Placeholder value awaited to obtain the current coroutine's cancellation token. |
|
Special placeholder object that can be 'co_await'ed from within a Task<T> or an AsyncGenerator<T> to obtain the current folly::Executor associated with the current coroutine. |
|
|
A SemiAwaitable object that allows you to reschedule the current coroutine onto the currently associated executor. |
A semi‐awaitable value that causes a safe‐point to be reached when awaited. |
|
Tag that, when thrown via |
|
True when |
|
|
True if the awaitable customizes the co_withAsyncStack CPO. |
True if T satisfies the awaitable interface. |
|
True if T satisfies the awaiter interface. |
|
True if T is a semi‐awaitable. |
|
Convenience: stopped returns V, error terminates (fatal). |
|
Policy that returns |
|
Convenience for void tasks: stopped returns unit, error terminates. |
|
True if T only completes with a value (not stopped or error). |
|
Policy value selecting termination on a stopped or error completion. |
Using Declarations
Name |
Description |
Re‐exports the standard coroutine handle type. |
|
Re‐exports the standard coroutine traits template. |
|
Re‐exports the standard no‐op coroutine factory. |
|
Re‐exports the standard no‐op coroutine handle type. |
|
Re‐exports the standard no‐op coroutine promise type. |
|
Re‐exports the standard always‐suspend awaitable. |
|
Re‐exports the standard never‐suspend awaitable. |
Created with MrDocs