Inherits dispenso::detail::FutureBase< Result >.
|
| Future () noexcept |
|
| Future (Future &&f) noexcept |
|
| Future (Base &&f) noexcept |
|
| Future (const Future &f) noexcept |
|
| Future (const Base &f) noexcept |
|
template<typename F , typename Schedulable > |
| Future (F &&f, Schedulable &schedulable, std::launch asyncPolicy=kNotAsync, std::launch deferredPolicy=std::launch::deferred) |
|
Future & | operator= (Future &&f) noexcept |
|
Future & | operator= (const Future &f) |
|
| ~Future ()=default |
|
bool | valid () const noexcept |
|
bool | is_ready () const |
|
void | wait () const |
|
template<class Rep , class Period > |
std::future_status | wait_for (const std::chrono::duration< Rep, Period > &timeoutDuration) const |
|
template<class Clock , class Duration > |
std::future_status | wait_until (const std::chrono::time_point< Clock, Duration > &timeoutTime) const |
|
Future | share () |
|
const Result & | get () const |
|
template<typename F , typename Schedulable > |
Future< detail::ResultOf< F, Future< Result > && > > | then (F &&f, Schedulable &sched, std::launch asyncPolicy=kNotAsync, std::launch deferredPolicy=std::launch::deferred) |
|
template<typename F > |
Future< detail::ResultOf< F, Future< Result > && > > | then (F &&f) |
|
A class that implements a hybrid of the interfaces for std::experimental::future, and std::experimental::shared_future. Future
acts like a shared_future
, but includes the share
function in order to enable generic code that may use the function. See https://en.cppreference.com/w/cpp/experimental/future for more details on the API, but some differences are notable.
dispenso::Future
are created and set into executors through their constructor, or through dispenso::async
dispenso::future
can be shared around like std::experimental::shared_future
, and wait/get functions may be called concurrently from multiple threads.
Future is thread-safe to call into, with the usual caveats (one thread may not be calling anything on the Future while another thread assigns to it or destructs it). It is thread-safe to assign or destruct on one copy of a Future while making calls on another copy of a Future with the same backing state.
Because Future is designed to work well with the dispenso TaskSet and ThreadPool, Future aggressively work steals in get
and wait
functions. This prevents deadlock due to thread pool resource starvation, similar to how TaskSets avoid that flavor of deadlock. It is important to note that deadlock is still possible due to traditional cyclic dependency, e.g. Future A and Future B which wait on each other. Just as with a cyclic mutex locking requirement, cyclic Future waits are considered programmer error.
Definition at line 69 of file future.h.