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

#include <Future.h>

Public Member Functions

 TPromise ()
 
 TPromise (TUniqueFunction< void()> &&CompletionCallback)
 
 TPromise (TPromise &&Other)=default
 
 TPromise (const TPromise &Other)=delete
 
TPromiseoperator= (TPromise &&Other)=default
 
TPromiseoperator= (const TPromise &Other)=delete
 
 ~TPromise ()
 
TFuture< ResultType > GetFuture ()
 
void SetValue (const SetType &Result)
 
void SetValue (SetType &&Result)
 
void SetValue ()
 
template<typename... ArgTypes>
void EmplaceValue (ArgTypes &&... Args)
 

Protected Member Functions

const TSharedPtr< StateType > & GetState ()
 

Detailed Description

template<typename ResultType>
class TPromise< ResultType >

Template for promises.

Constructor & Destructor Documentation

◆ TPromise() [1/4]

template<typename ResultType >
TPromise< ResultType >::TPromise ( )
inline

Default constructor (creates a new shared state).

◆ TPromise() [2/4]

template<typename ResultType >
TPromise< ResultType >::TPromise ( TUniqueFunction< void()> &&  CompletionCallback)
inline

Create and initialize a new instance with a callback.

Parameters
CompletionCallbackA function that is called when the future state is completed.

◆ TPromise() [3/4]

template<typename ResultType >
TPromise< ResultType >::TPromise ( TPromise< ResultType > &&  Other)
default

◆ TPromise() [4/4]

template<typename ResultType >
TPromise< ResultType >::TPromise ( const TPromise< ResultType > &  Other)
delete

◆ ~TPromise()

template<typename ResultType >
TPromise< ResultType >::~TPromise ( )
inline

Destructor.

Member Function Documentation

◆ EmplaceValue()

template<typename ResultType >
template<typename... ArgTypes>
void TPromise< ResultType >::EmplaceValue ( ArgTypes &&...  Args)
inline

Sets the promised result.

The result must be set only once. An assertion will be triggered if this method is called a second time.

Parameters
ArgsThe arguments to forward to the constructor of the result.

◆ GetFuture()

template<typename ResultType >
TFuture< ResultType > TPromise< ResultType >::GetFuture ( )
inline

Gets a TFuture object associated with the shared state of this promise.

Returns
The TFuture object.

◆ GetState()

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

Gets the shared state object.

Returns
The shared state object.

◆ operator=() [1/2]

template<typename ResultType >
TPromise & TPromise< ResultType >::operator= ( const TPromise< ResultType > &  Other)
delete

◆ operator=() [2/2]

template<typename ResultType >
TPromise & TPromise< ResultType >::operator= ( TPromise< ResultType > &&  Other)
default

◆ SetValue() [1/3]

template<typename ResultType >
void TPromise< ResultType >::SetValue ( )
inline

◆ SetValue() [2/3]

template<typename ResultType >
void TPromise< ResultType >::SetValue ( const SetType &  Result)
inline

Sets the promised result.

The result must be set only once. An assertion will be triggered if this method is called a second time.

Parameters
ResultThe result value to set.

◆ SetValue() [3/3]

template<typename ResultType >
void TPromise< ResultType >::SetValue ( SetType &&  Result)
inline

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