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.
Synopsis
Declared in <folly/coro/SharedPromise.h>
template<typename T>
class SharedPromise;
Description
It has the same behavior as folly::SharedPromise<>. This includes the difference in behavior of folly::SharedPromise and folly::Promise with regards to invalid promise exceptions ‐‐ when SharedPromise<> is moved from, calling setValue(), setTry(), or setException() don't result in a PromiseInvalid exception.
Member Functions
Name |
Description |
|
Constructors |
Assignment operators |
|
Returns a future that is fulfilled when the user sets a value on the promise. Because this is a coro::Future, it supports cancellation. |
|
Returns true if the promise has either a value or an exception set. |
|
Returns either an optional holding the result or an empty optional depending on whether or not (respectively) the promise has been fulfilled (i.e., |
|
Sets an exception in the promise. |
|
Sets a folly::Try object in the promise. |
|
|
|
Returns the number of futures associated with the SharedPromise. |
Created with MrDocs