UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TFutureBase< ResultType > Class Template Reference

#include <Future.h>

+ Inheritance diagram for TFutureBase< ResultType >:

Public Types

using MutableResultType = typename StateType::MutableResultType
 
using ConstResultType = typename StateType::ConstResultType
 
using RvalueResultType = typename StateType::RvalueResultType
 

Public Member Functions

ConstResultType Get () const
 
ConstResultType Get () const UE_LIFETIMEBOUND
 
bool IsReady () const
 
bool IsValid () const
 
void Wait () const
 
bool WaitFor (const FTimespan &Duration) const
 
bool WaitUntil (const FDateTime &Time) const
 

Protected Types

using StateType = TFutureState< ResultType >
 

Protected Member Functions

 TFutureBase ()=default
 
 TFutureBase (TSharedPtr< StateType > &&InState)
 
 TFutureBase (const TSharedPtr< StateType > &InState)
 
const TSharedPtr< StateType > & GetState () const
 
template<typename Func >
auto Then (Func Continuation)
 
template<typename Func >
auto Next (Func Continuation)
 
void Reset ()
 

Detailed Description

template<typename ResultType>
class TFutureBase< ResultType >

Abstract base template for futures and shared futures.

Member Typedef Documentation

◆ ConstResultType

template<typename ResultType >
using TFutureBase< ResultType >::ConstResultType = typename StateType::ConstResultType

◆ MutableResultType

template<typename ResultType >
using TFutureBase< ResultType >::MutableResultType = typename StateType::MutableResultType

◆ RvalueResultType

template<typename ResultType >
using TFutureBase< ResultType >::RvalueResultType = typename StateType::RvalueResultType

◆ StateType

template<typename ResultType >
using TFutureBase< ResultType >::StateType = TFutureState<ResultType>
protected

Constructor & Destructor Documentation

◆ TFutureBase() [1/3]

template<typename ResultType >
TFutureBase< ResultType >::TFutureBase ( )
protecteddefault

Default constructor.

◆ TFutureBase() [2/3]

template<typename ResultType >
TFutureBase< ResultType >::TFutureBase ( TSharedPtr< StateType > &&  InState)
inlineprotected

Creates and initializes a new instance.

Parameters
InStateThe shared state to initialize with.

◆ TFutureBase() [3/3]

template<typename ResultType >
TFutureBase< ResultType >::TFutureBase ( const TSharedPtr< StateType > &  InState)
inlineprotected

Member Function Documentation

◆ Get() [1/2]

template<typename ResultType >
ConstResultType TFutureBase< ResultType >::Get ( ) const
inline

Gets the future's result.

Returns
The result as a const reference, or the same reference if the future holds a reference, or void if the future holds a void.
Note
Not equivalent to std::future::get(). The future remains valid.

◆ Get() [2/2]

template<typename ResultType >
ConstResultType TFutureBase< ResultType >::Get ( ) const
inline

◆ GetState()

template<typename ResultType >
const TSharedPtr< StateType > & TFutureBase< ResultType >::GetState ( ) const
inlineprotected

Gets the shared state object.

Returns
The shared state object.

◆ IsReady()

template<typename ResultType >
bool TFutureBase< ResultType >::IsReady ( ) const
inline

Checks whether this future object has its value set.

Returns
true if this future has a shared state and the value has been set, false otherwise.
See also
IsValid

◆ IsValid()

template<typename ResultType >
bool TFutureBase< ResultType >::IsValid ( ) const
inline

Checks whether this future object has a valid state.

Returns
true if the state is valid, false otherwise.
See also
IsReady

◆ Next()

template<typename ResultType >
template<typename Func >
auto TFutureBase< ResultType >::Next ( Func  Continuation)
protected

Convenience wrapper for Then that set a completion callback that will be called once the future completes or immediately if already completed

Parameters
Continuationa continuation taking an argument of type ResultType
Returns
nothing at the moment but could return another future to allow future chaining

◆ Reset()

template<typename ResultType >
void TFutureBase< ResultType >::Reset ( )
inlineprotected

Reset the future. Resetting a future removes any continuation from its shared state and invalidates it. Useful for discarding yet to be completed future cleanly.

◆ Then()

template<typename ResultType >
template<typename Func >
auto TFutureBase< ResultType >::Then ( Func  Continuation)
protected

Set a completion callback that will be called once the future completes or immediately if already completed

Parameters
Continuationa continuation taking an argument of type TFuture<ResultType>
Returns
nothing at the moment but could return another future to allow future chaining

◆ Wait()

template<typename ResultType >
void TFutureBase< ResultType >::Wait ( ) const
inline

Blocks the calling thread until the future result is available.

Note that this method may block forever if the result is never set. Use the WaitFor or WaitUntil methods to specify a maximum timeout for the wait.

See also
WaitFor, WaitUntil

◆ WaitFor()

template<typename ResultType >
bool TFutureBase< ResultType >::WaitFor ( const FTimespan Duration) const
inline

Blocks the calling thread until the future result is available or the specified duration is exceeded.

Parameters
DurationThe maximum time span to wait for the future result.
Returns
true if the result is available, false otherwise.
See also
Wait, WaitUntil

◆ WaitUntil()

template<typename ResultType >
bool TFutureBase< ResultType >::WaitUntil ( const FDateTime Time) const
inline

Blocks the calling thread until the future result is available or the specified time is hit.

Parameters
TimeThe time until to wait for the future result (in UTC).
Returns
true if the result is available, false otherwise.
See also
Wait, WaitUntil

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