14 template<
typename ReturnType>
17 return *(
reinterpret_cast<ReturnType*
>(
uintptr_t(1)));
31 template<
typename ReturnType>
88 template<
typename ReturnType>
99 checkf(
false,
TEXT(
"trying to Launch an empty AwaitableTask"));
109 checkf(
false,
TEXT(
"trying to get the Result of an empty AwaitableTask"));
133 template<
typename ReturnType>
140 template<
typename ReturnType>
149 template<
typename PromiseType>
152 using ReturnType =
typename PromiseType::ReturnType;
164 return LocalPromise->TryLaunch();
170 LocalPromise->IncrementRefCount();
176 return LocalPromise->GetResult();
182 return LocalPromise->IsLaunched();
193 return LocalPromise->IsCompleted();
204 template<
typename TReturnType,
typename CallableType>
217 std::atomic_int ReferenceCounter{ 2 };
220 inline void Execute()
222 ReturnValue =
Invoke(Callable);
230 template<
typename CallableT>
246 return !Task.IsReady();
251 ReferenceCounter.fetch_add(1, std::memory_order_release);
256 return Completed.IsNotified();
261 int LocalCounter = ReferenceCounter.fetch_sub(1, std::memory_order_release);
270 if (Task.TryCancel())
283 template<
typename CallableType>
295 std::atomic_int ReferenceCounter{ 2 };
298 inline void Execute()
308 template<
typename CallableT>
324 return !Task.IsReady();
329 ReferenceCounter.fetch_add(1, std::memory_order_release);
334 return Completed.IsNotified();
339 int LocalCounter = ReferenceCounter.fetch_sub(1, std::memory_order_release);
353 if (Task.TryCancel())
369template<
typename ReturnType>
378 template<
typename R,
typename C>
402 PromiseVTable =
Other.PromiseVTable;
403 GetVtable()->IncrementRefCount();
416 PromiseVTable =
Other.PromiseVTable;
417 GetVtable()->IncrementRefCount();
435 template<
typename CallableT>
441 static_assert(std::is_convertible<ReturnType,
decltype(Callable())>::value,
"Callable has no matching Return Type");
448 template<
typename CallableT>
457 return GetVtable()->TryLaunch();
461 template<
typename CallableT>
471 template<
typename CallableT>
480 GetVtable()->Finish();
486 return GetVtable()->IsLaunched();
492 return GetVtable()->IsValid();
498 return GetVtable()->IsCompleted();
507 return GetVtable()->GetResult();
511 template<
typename PromiseType = TPromiseVTableBase<ReturnType>>
517 template<
typename PromiseType = TPromiseVTableBase<ReturnType>>
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define checkNoEntry()
Definition AssertionMacros.h:316
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define verify(expr)
Definition AssertionMacros.h:319
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_LAUNDER(x)
Definition Launder.h:8
void Init()
Definition LockFreeList.h:4
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
memcpy(InputBufferBase, BinkBlocksData, BinkBlocksSize)
Definition AwaitableTask.h:27
Definition AwaitableTask.h:33
virtual bool IsLaunched() const
Definition AwaitableTask.h:59
virtual void Finish()
Definition AwaitableTask.h:77
TPromiseVTableBase(FPromiseBase *InPromise)
Definition AwaitableTask.h:36
virtual bool IsCompleted() const
Definition AwaitableTask.h:71
virtual bool TryLaunch()
Definition AwaitableTask.h:42
FPromiseBase * Promise
Definition AwaitableTask.h:35
TPromiseVTableBase & operator=(const TPromiseVTableBase &Other)
Definition AwaitableTask.h:134
virtual ReturnType GetResult()
Definition AwaitableTask.h:53
TPromiseVTableBase()=default
virtual bool IsValid() const
Definition AwaitableTask.h:65
virtual void IncrementRefCount()
Definition AwaitableTask.h:48
Definition AwaitableTask.h:90
void IncrementRefCount() override
Definition AwaitableTask.h:103
bool IsValid() const override
Definition AwaitableTask.h:118
bool IsCompleted() const override
Definition AwaitableTask.h:123
bool TryLaunch() override
Definition AwaitableTask.h:97
ReturnType GetResult() override
Definition AwaitableTask.h:107
void Finish() override
Definition AwaitableTask.h:128
bool IsLaunched() const override
Definition AwaitableTask.h:113
TPromiseVTableDummy()
Definition AwaitableTask.h:92
Definition AwaitableTask.h:151
ReturnType GetResult() override
Definition AwaitableTask.h:173
bool TryLaunch() override
Definition AwaitableTask.h:161
TPromiseVTable(FPromiseBase *InPromise)
Definition AwaitableTask.h:155
bool IsCompleted() const override
Definition AwaitableTask.h:190
bool IsLaunched() const override
Definition AwaitableTask.h:179
void Finish() override
Definition AwaitableTask.h:196
void IncrementRefCount() override
Definition AwaitableTask.h:167
bool IsValid() const override
Definition AwaitableTask.h:185
Definition AwaitableTask.h:285
void GetResult()
Definition AwaitableTask.h:351
bool IsCompleted() const
Definition AwaitableTask.h:332
bool TryLaunch()
Definition AwaitableTask.h:317
void Finish()
Definition AwaitableTask.h:337
bool IsLaunched() const
Definition AwaitableTask.h:322
void ReturnType
Definition AwaitableTask.h:287
void IncrementRefCount()
Definition AwaitableTask.h:327
TPromise(const TCHAR *DebugName, LowLevelTasks::ETaskPriority Priority, CallableT &&InCallable)
Definition AwaitableTask.h:309
Definition AwaitableTask.h:206
bool TryLaunch()
Definition AwaitableTask.h:239
ReturnType GetResult()
Definition AwaitableTask.h:268
TReturnType ReturnType
Definition AwaitableTask.h:208
bool IsLaunched() const
Definition AwaitableTask.h:244
bool IsCompleted() const
Definition AwaitableTask.h:254
void IncrementRefCount()
Definition AwaitableTask.h:249
void Finish()
Definition AwaitableTask.h:259
TPromise(const TCHAR *DebugName, LowLevelTasks::ETaskPriority Priority, CallableT &&InCallable)
Definition AwaitableTask.h:231
Definition AwaitableTask.h:371
TAwaitableTask(ThisClass &&Other)
Definition AwaitableTask.h:406
bool IsCompleted() const
Definition AwaitableTask.h:496
ThisClass & operator=(const ThisClass &Other)
Definition AwaitableTask.h:411
void Init(const TCHAR *DebugName, LowLevelTasks::ETaskPriority Priority, CallableT &&Callable)
Definition AwaitableTask.h:436
void Init(const TCHAR *DebugName, CallableT &&Callable)
Definition AwaitableTask.h:449
bool InitAndLaunch(const TCHAR *DebugName, LowLevelTasks::ETaskPriority Priority, CallableT &&Callable)
Definition AwaitableTask.h:462
void Reset()
Definition AwaitableTask.h:478
TAwaitableTask(const ThisClass &Other)
Definition AwaitableTask.h:400
bool InitAndLaunch(const TCHAR *DebugName, CallableT &&Callable)
Definition AwaitableTask.h:472
~TAwaitableTask()
Definition AwaitableTask.h:395
TAwaitableTask()
Definition AwaitableTask.h:389
bool TryLaunch()
Definition AwaitableTask.h:455
ReturnType Await()
Definition AwaitableTask.h:504
bool IsLaunched() const
Definition AwaitableTask.h:484
bool IsValid() const
Definition AwaitableTask.h:490
Definition ManualResetEvent.h:15
Definition AwaitableTask.h:13
ReturnType MakeDummyValue()
Definition AwaitableTask.h:15
void MakeDummyValue< void >()
Definition AwaitableTask.h:21
ETaskPriority
Definition Task.h:18
UE_FORCEINLINE_HINT bool TryLaunch(FTask &Task, EQueuePreference QueuePreference=EQueuePreference::DefaultPreference, bool bWakeUpWorker=true)
Definition Scheduler.h:181
Definition IsInvocable.h:47