ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
original::async::future< TYPE > Class Template Referencefinal

Represents a one-shot future result of an asynchronous computation. More...

#include <async.h>

Inheritance diagram for original::async::future< TYPE >:
Inheritance graph
Collaboration diagram for original::async::future< TYPE >:
Collaboration graph

Public Member Functions

 future (const future &)=delete
 
futureoperator= (const future &)=delete
 
 future (future &&)=default
 
futureoperator= (future &&)=default
 
bool valid () const noexcept override
 Checks if the future is valid (has an associated async wrapper)
 
sharedFuture< TYPEshare ()
 Converts this future to a shared future.
 
TYPE result ()
 Gets the result (blocks until ready)
 
bool ready () const override
 Checks if the result is ready.
 
std::exception_ptr exception () const noexcept override
 Gets the exception if computation failed.
 
void wait () const override
 Waits until the result becomes ready.
 
bool waitFor (time::duration timeout) const override
 Waits for the result with a timeout.
 

Friends

class async
 

Detailed Description

template<typename TYPE>
class original::async::future< TYPE >

Represents a one-shot future result of an asynchronous computation.

Template Parameters
TYPEThe result type of the computation

future allows retrieving the result exactly once. After consumption, the value is moved out of storage.

Member Function Documentation

◆ exception()

template<typename TYPE >
std::exception_ptr original::async::future< TYPE >::exception ( ) const
overridevirtualnoexcept

Gets the exception if computation failed.

Returns
Exception pointer (nullptr if no exception)

Implements original::async::futureBase.

◆ ready()

template<typename TYPE >
bool original::async::future< TYPE >::ready ( ) const
overridevirtual

Checks if the result is ready.

Returns
True if result is available

Implements original::async::futureBase.

◆ result()

template<typename TYPE >
TYPE original::async::future< TYPE >::result ( )

Gets the result (blocks until ready)

Returns
The computed result
Exceptions
std::exceptionif the computation threw an exception

◆ share()

Converts this future to a shared future.

Returns
A shared future that shares the same async wrapper

◆ valid()

template<typename TYPE >
bool original::async::future< TYPE >::valid ( ) const
overridevirtualnoexcept

Checks if the future is valid (has an associated async wrapper)

Returns
True if valid, false otherwise

Implements original::async::futureBase.

◆ wait()

template<typename TYPE >
void original::async::future< TYPE >::wait ( ) const
overridevirtual

Waits until the result becomes ready.

Implements original::async::futureBase.

◆ waitFor()

template<typename TYPE >
bool original::async::future< TYPE >::waitFor ( time::duration  timeout) const
overridevirtual

Waits for the result with a timeout.

Parameters
timeoutMaximum time to wait
Returns
True if result is ready within timeout, false otherwise

Implements original::async::futureBase.


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