The write side of a promise/future contract used to fulfill a Future.
Synopsis
Declared in <folly/coro/Promise.h>
template<typename T>
class Promise;
Member Functions
Name |
Description |
|
Constructors |
|
Destroys the promise, breaking it if it was never fulfilled. |
Assignment operators |
|
Returns the cancellation token associated with this promise. |
|
Returns whether the promise has already been fulfilled. |
|
Fulfills the promise with an exception. |
|
Fulfills the promise with a Try holding a value or exception. |
|
Fulfills the promise with a value. |
|
Fulfills the promise with an exception if not already fulfilled. |
|
Fulfills the promise with an exception returned from calling func if not already fulfilled. |
|
Fulfills the promise with a Try if not already fulfilled. |
|
Fulfills the promise with a value if not already fulfilled. |
|
Fulfills the promise with a value/Try returned from calling func if not already fulfilled. |
|
Returns whether the promise refers to a valid shared state. |
Friends
Name |
Description |
Non-Member Functions
Name |
Description |
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. |
Created with MrDocs