ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
original::async::promise< void, Callback > Class Template Reference

Specialization of promise for void results. More...

#include <async.h>

Collaboration diagram for original::async::promise< void, Callback >:
Collaboration graph

Public Member Functions

 promise (const promise &)=delete
 
promiseoperator= (const promise &)=delete
 
 promise (promise &&other) noexcept
 
promiseoperator= (promise &&other) noexcept
 
 promise ()=default
 Default constructor creates an invalid promise.
 
 promise (Callback &&c)
 Constructs a promise with a computation callback.
 
future< voidgetFuture () const
 Gets the future associated with this promise.
 
bool valid () const noexcept
 Checks if the promise is still valid.
 
std::function< void()> function ()
 Extracts the computation function from the promise.
 
void run ()
 Executes the computation and marks completion in the associated future.
 

Detailed Description

template<typename Callback>
class original::async::promise< void, Callback >

Specialization of promise for void results.

Template Parameters
CallbackThe type of the computation callback

Same single-use semantics as the general promise template, but for void-returning computations.

Constructor & Destructor Documentation

◆ promise()

template<typename Callback >
original::async::promise< void, Callback >::promise ( Callback &&  c)
explicit

Constructs a promise with a computation callback.

Parameters
cCallback that will execute the computation

Member Function Documentation

◆ function()

template<typename Callback >
std::function< void()> original::async::promise< void, Callback >::function ( )

Extracts the computation function from the promise.

Returns
The computation function that was associated with this promise
Exceptions
sysErrorif the promise is invalid

◆ getFuture()

Gets the future associated with this promise.

Returns
A future that will receive the completion signal

◆ run()

Executes the computation and marks completion in the associated future.

Exceptions
sysErrorif the promise is invalid
Anyexception thrown by the computation function

◆ valid()

template<typename Callback >
bool original::async::promise< void, Callback >::valid ( ) const
noexcept

Checks if the promise is still valid.

Returns
True if the promise holds a valid computation that hasn't been used yet

The documentation for this class was generated from the following file: