libcoro  1.0
Coroutine support library for C++20
Classes | Public Types | Public Member Functions | List of all members
coro::promise< T, atomic > Class Template Reference

Carries reference to future<T>, callable, sets value of an associated future<T> More...

Classes

class  notify
 contain notification to be delivered to the asociated future More...
 

Public Types

using FutureType = future< T >
 Associated future. More...
 

Public Member Functions

 promise ()=default
 construct unbound promise More...
 
 promise (FutureType *ptr)
 Bound promise to future. More...
 
 promise (promise &&other)
 Move. More...
 
template<bool x>
 promise (promise< T, x > &&other)
 Move change MT Safety. More...
 
promiseoperator= (promise &&other)
 Assign by move. More...
 
 ~promise ()
 Dtor - if future is pending, cancels it. More...
 
notify cancel ()
 cancel the future (resolve without value) More...
 
template<typename ... Args>
notify operator() (Args &&... args)
 set value More...
 
notify reject (std::exception_ptr e)
 reject the future with exception More...
 
notify reject ()
 reject or cancel the future with exception More...
 
template<typename E >
notify reject (E &&exception)
 Reject with exception. More...
 
FutureTyperelease ()
 Release the future pointer from the promise object. More...
 
const FutureTypeget_future () const
 Retrieve pointer to an associated future. More...
 
template<bool f>
promiseoperator+= (promise< T, f > &other)
 Combine two promises into one. More...
 
template<bool f>
promise operator+ (promise< T, f > &other)
 Combine two promises into one. More...
 

Detailed Description

template<typename T, bool atomic>
class coro::promise< T, atomic >

Carries reference to future<T>, callable, sets value of an associated future<T>

Template Parameters
Tcontains type of associated future and the same type to be constructed.
atomicset true to make promise atomic - it can be accessed from multiple threads at same time. Default value is false, so promise is not atomic (however it is faster to handle). You can change this flag anytime,
See also
atomic_promise

Definition at line 73 of file future.h.


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