Portable concurrency
0.11.0
|
The class template future provides a mechanism to access the result of asynchronous operations. More...
Public Member Functions | |
future () noexcept=default | |
future (future &&rhs) noexcept=default | |
future (const future &)=delete | |
future & | operator= (const future &)=delete |
future & | operator= (future &&rhs) noexcept=default |
~future ()=default | |
shared_future< T > | share () noexcept |
T | get () |
Get the result of asynchronyous operation stored in this future object. More... | |
void | wait () const |
bool | valid () const noexcept |
bool | is_ready () const |
template<typename F > | |
void | notify (F &¬ification) |
template<typename E , typename F > | |
void | notify (E &&exec, F &¬ification) |
future | detach () |
The class template future provides a mechanism to access the result of asynchronous operations.
Copy constructor is explicitly deleted. Future object is not copyable.
|
default |
Destroys associated shared state and cancel not yet started operations.
future detach | ( | ) |
Prevents cancellation of the operations of this future value calculation on its destruction.
T get | ( | ) |
Get the result of asynchronyous operation stored in this future object.
If the value is not yet set block current thread and wait for it. The value stored in the future is moved to the caller.
bool is_ready | ( | ) | const |
Checks if associated shared state is ready
void notify | ( | E && | exec, |
F && | notification | ||
) |
Adds notification function to be called when this future object becomes ready.
Notification function must meet MoveConstructable
, MoveAssignable
and Callable
(with signature void()
) standard library requirements.
Both exec
and notification
objects are decay copied on the caller thread. Once this future object becomes ready post(exec, std::move(notification))
is executed on unspecified thread. Implementation provide strict guaranty that notification
is scheduled for execution at most once. If this->is_ready() == true
then notification
is scheduled for execution immediatelly.
void notify | ( | F && | notification | ) |
Adds notification function to be called when this future object becomes ready.
Equivalent to this->notify(inplace_executor, notification)
.
notification
execution is unspecified. Copy assignment operator is explicitly deleted. Future object is not copyable.
Move assignmet
|
noexcept |
Creates shared_future object and move ownership on the shared state associated to this object to it
|
noexcept |
Checks if future has associated shared state
void wait | ( | ) | const |
Blocks curent thread until this future object becomes ready.