UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AsyncResult.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Async/Future.h"
7
9class IAsyncTask;
10
16template<typename ResultType>
18{
19public:
20
23
31 template <typename ArgType,
32 typename = std::enable_if_t<std::is_same_v<ArgType, ResultType> && std::is_reference_v<const ArgType&>>>
33 TAsyncResult(const ArgType& Result)
34 {
36 Promise.SetValue(Result);
37 Future = Promise.GetFuture();
38 }
39
52
55 : Future(MoveTemp(Other.Future))
56 , Progress(Other.Progress)
57 , Task(Other.Task)
58 {
59 Other.Progress.Reset();
60 Other.Task.Reset();
61 }
62
63public:
64
67 {
68 Future = MoveTemp(Other.Future);
69 Progress = Other.Progress;
70 Task = Other.Task;
71
72 Other.Progress.Reset();
73 Other.Task.Reset();
74
75 return *this;
76 }
77
78public:
79
86 {
87 return Future;
88 }
89
96 {
97 return Progress;
98 }
99
106 {
107 return Task;
108 }
109
110private:
111
114
117
118private:
119
121 TFuture<ResultType> Future;
122
125
128};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition IAsyncProgress.h:13
Definition IAsyncTask.h:37
Definition AsyncResult.h:18
TSharedPtr< IAsyncProgress > GetProgess() const
Definition AsyncResult.h:95
const TFuture< ResultType > & GetFuture() const
Definition AsyncResult.h:85
TAsyncResult & operator=(TAsyncResult &&Other)
Definition AsyncResult.h:66
TAsyncResult(TAsyncResult &&Other)
Definition AsyncResult.h:54
TAsyncResult(const ArgType &Result)
Definition AsyncResult.h:33
TSharedPtr< IAsyncTask > GetTask() const
Definition AsyncResult.h:105
TAsyncResult(TFuture< ResultType > &&InFuture, const TSharedPtr< IAsyncProgress > &InProgress, const TSharedPtr< IAsyncTask > &InTask)
Definition AsyncResult.h:47
TAsyncResult()
Definition AsyncResult.h:22
Definition Future.h:393
Definition Future.h:541
TFuture< ResultType > GetFuture()
Definition Future.h:587
void SetValue(const SetType &Result)
Definition Future.h:603
Definition SharedPointer.h:692
UE_FORCEINLINE_HINT void Reset()
Definition SharedPointer.h:1120