C/C++ API Reference
Loading...
Searching...
No Matches
pw::async2::BoxedFuture< T > Class Template Referencefinal

Overview

template<typename T>
class pw::async2::BoxedFuture< T >

A type-erased future that produces a value of type T.

BoxedFuture wraps another future, storing it dynamically via a pw::Allocator. This hides the concrete type of the future, which is useful when storing or returning futures of different concrete types.

Public Types

using value_type = T
 

Public Member Functions

 BoxedFuture ()
 Constructs an empty BoxedFuture.
 
 BoxedFuture (const BoxedFuture &)=delete
 
BoxedFutureoperator= (const BoxedFuture &)=delete
 
 BoxedFuture (BoxedFuture &&other) noexcept
 
BoxedFutureoperator= (BoxedFuture &&other) noexcept
 
bool is_pendable () const
 Returns whether Pend() can be called.
 
bool is_complete () const
 Returns whether the future has completed.
 
Poll< T > Pend (Context &cx)
 Advances the future.
 

Friends

template<typename FutureType >
BoxedFuture< typename std::decay_t< FutureType >::value_type > BoxFuture (Allocator &alloc, FutureType &&future)
 

Friends And Related Function Documentation

◆ BoxFuture

template<typename T >
template<typename FutureType >
BoxedFuture< typename std::decay_t< FutureType >::value_type > BoxFuture ( Allocator alloc,
FutureType &&  future 
)
friend

Type-erases a future, wrapping it in a BoxedFuture allocated using the specified allocator.

Example:

BoxFuture(allocator, SomethingReturningAFuture());
if (future.is_pendable()) {
// Use the future
} else {
// Handle allocation failure
}
Definition: box.h:65
bool is_pendable() const
Returns whether Pend() can be called.
Definition: box.h:89
friend BoxedFuture< typename std::decay_t< FutureType >::value_type > BoxFuture(Allocator &alloc, FutureType &&future)
Definition: box.h:160

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