UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TaskGraphInterfaces.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 TaskGraphInterfaces.h: TaskGraph library
5=============================================================================*/
6
7#pragma once
8
9#include "CoreTypes.h"
12#include "Containers/Array.h"
14#include "Templates/Function.h"
15#include "Delegates/Delegate.h"
18#include "Stats/Stats.h"
19#include "HAL/IConsoleManager.h"
20#include "HAL/Event.h"
25#include "Misc/MemStack.h"
26#include "Misc/Timeout.h"
27#include "Templates/Atomic.h"
28#include "Templates/Models.h"
30
32
33#include "Async/TaskGraphFwd.h"
34#include "Async/TaskTrace.h"
35#include "Tasks/TaskPrivate.h"
37
38#if !defined(STATS)
39#error "STATS must be defined as either zero or one."
40#endif
41
42// what level of checking to perform...normally checkSlow but could be ensure or check
43#define checkThreadGraph checkSlow
44
45//#define checkThreadGraph(x) ((x)||((*(char*)3) = 0))
46
48
53
54namespace ENamedThreads
55{
109
111 {
112 private:
113 // These are private to prevent direct access by anything except the friend functions below
114 static CORE_API TAtomic<Type> RenderThread;
115 static CORE_API TAtomic<Type> RenderThread_Local;
116
117 friend Type GetRenderThread();
119 friend void SetRenderThread(Type Thread);
120 friend void SetRenderThread_Local(Type Thread);
121 };
122
124 {
125 return FRenderThreadStatics::RenderThread.Load(EMemoryOrder::Relaxed);
126 }
127
129 {
130 return FRenderThreadStatics::RenderThread_Local.Load(EMemoryOrder::Relaxed);
131 }
132
134 {
135 FRenderThreadStatics::RenderThread.Store(Thread, EMemoryOrder::Relaxed);
136 }
137
139 {
140 FRenderThreadStatics::RenderThread_Local.Store(Thread, EMemoryOrder::Relaxed);
141 }
142
143 // these allow external things to make custom decisions based on what sorts of task threads we are running now.
144 // this are bools to allow runtime tuning.
147
152
157
162
164 {
166 check(Result >= 0 && Result < NumThreadPriorities);
167 return Result;
168 }
169
170 inline Type SetPriorities(Type ThreadAndIndex, Type ThreadPriority, Type TaskPriority)
171 {
172 check(
173 !(ThreadAndIndex & ~ThreadIndexMask) && // not a thread index
174 !(ThreadPriority & ~ThreadPriorityMask) && // not a thread priority
175 (ThreadPriority & ThreadPriorityMask) != ThreadPriorityMask && // not a valid thread priority
176 !(TaskPriority & ~TaskPriorityMask) // not a task priority
177 );
178 return Type(ThreadAndIndex | ThreadPriority | TaskPriority);
179 }
180
181 inline Type SetPriorities(Type ThreadAndIndex, int32 PriorityIndex, bool bHiPri)
182 {
183 check(
184 !(ThreadAndIndex & ~ThreadIndexMask) && // not a thread index
185 PriorityIndex >= 0 && PriorityIndex < NumThreadPriorities // not a valid thread priority
186 );
187 return Type(ThreadAndIndex | (PriorityIndex << ThreadPriorityShift) | (bHiPri ? HighTaskPriority : NormalTaskPriority));
188 }
189
191 {
192 check(
193 !(ThreadAndIndex & ~ThreadIndexMask) && // not a thread index
194 !(ThreadPriority & ~ThreadPriorityMask) && // not a thread priority
195 (ThreadPriority & ThreadPriorityMask) != ThreadPriorityMask // not a valid thread priority
196 );
197 return Type(ThreadAndIndex | ThreadPriority);
198 }
199
201 {
202 check(
203 !(ThreadAndIndex & ~ThreadIndexMask) && // not a thread index
204 !(TaskPriority & ~TaskPriorityMask) // not a task priority
205 );
206 return Type(ThreadAndIndex | TaskPriority);
207 }
208}
209
211
213{
214 FString RawSetting;
215 FString FullHelpText;
217 ENamedThreads::Type ThreadPriority;
218 ENamedThreads::Type TaskPriority;
219 ENamedThreads::Type TaskPriorityIfForcedToNormalThreadPriority;
220
221 static FString CreateFullHelpText(const TCHAR* Name, const TCHAR* OriginalHelp);
223 void OnSettingChanged(IConsoleVariable* Variable);
224
225public:
227
229 {
230 // if we don't have the high priority thread that was asked for, or we are downgrading thread priority due to power saving
231 // then use a normal thread priority with the backup task priority
233 {
234 return ENamedThreads::SetTaskPriority(Thread, TaskPriorityIfForcedToNormalThreadPriority);
235 }
236 // if we don't have the background priority thread that was asked for, then use a normal thread priority with the backup task priority
238 {
239 return ENamedThreads::SetTaskPriority(Thread, TaskPriorityIfForcedToNormalThreadPriority);
240 }
241 return ENamedThreads::SetPriorities(Thread, ThreadPriority, TaskPriority);
242 }
243};
244
245
256
259
262
265{
266 friend class FBaseGraphTask;
268
276
277public:
278
280 {
281 }
282
283 // Startup, shutdown and singleton API
284
289 static CORE_API void Startup(int32 NumThreads);
293 static CORE_API void Shutdown();
297 static CORE_API bool IsRunning();
303
308 static bool IsMultithread();
309
312
314 virtual bool IsCurrentThreadKnown() = 0;
315
321
327
333
336
337 // External Thread API
338
343 virtual void AttachToThread(ENamedThreads::Type CurrentThread)=0;
344
350
356
360 virtual void RequestReturn(ENamedThreads::Type CurrentThread)=0;
361
369
370
389
392
402
410
420
425
438
440
441 virtual void StallForTuning(int32 Index, bool Stall) = 0;
442
447 virtual void AddShutdownCallback(TFunction<void()>& Callback) = 0;
448
450
456};
457
459{
460 static constexpr uint32 BlockSize = 64 * 1024;
461 static constexpr bool AllowOversizedBlocks = false;
462 static constexpr bool RequiresAccurateSize = false;
463 static constexpr bool InlineBlockAllocation = true;
464 static constexpr const char* TagName = "TaskGraphLinear";
465
467};
468
471{
472public:
473 // These functions handle integration with FTaskBase and the named thread executor and should not be called directly
475 : FTaskBase(/*InitRefCount=*/ 1, false /* bUnlockPrerequisites */)
476 {
477 if (InPrerequisites != nullptr)
478 {
479 AddPrerequisites(*InPrerequisites, false /* bLockPrerequisite */);
480 }
481
483 }
484
489
490 inline void Execute(TArray<FBaseGraphTask*>& NewTasks, ENamedThreads::Type CurrentThread, bool bDeleteOnCompletion)
491 { // only called for named thread tasks, normal tasks are executed using `FTaskBase` API directly (see `TGraphTask`)
492 checkSlow(NewTasks.Num() == 0);
496 ReleaseInternalReference(); // named tasks are executed by named threads, outside of the scheduler
497 }
498
499
502 {
503 return this;
504 }
505
511 {
512 if (!NestedTask)
513 {
514 return;
515 }
516
517 if (IsTaskEvent())
518 { // TaskEvent can't have nested tasks, add it as a prerequisite instead to retain backward compatibility
520 }
521 else
522 {
523 checkSlow(UE::Tasks::Private::GetCurrentTask() == this); // a nested task can be added only from inside of parent's execution
525 }
526 }
527
529 bool IsComplete() const
530 {
531 return IsCompleted();
532 }
533
536
542
548 {
549 if (IsTaskEvent())
550 {
551 // An event is not "in the system" until it's triggered, and should be kept alive only by external references. Once it's triggered it's in the system
552 // and can outlive external references, so we need to keep it alive by holding an internal reference. It will be released when the event is signaled
553 AddRef();
554 }
555 TryLaunch(0);
556 }
557
563
564 UE_DEPRECATED(5.6, "Call AddPrerequisites separately if you need to add new tasks before dispatch")
566 {
567 check(NewTasks.Num() == 0); // the feature is not used
569 }
570
572 { // incompatible with the new API that requires debug name during task construction and doesn't allow to set it later. "debug name" feature was added
573 // to the old API recently, is used only in a couple of places and will be fixed manually by switching to the new API
574 }
575
578 {
579 // local queue have to be handled by the original TaskGraph implementation. Tasks System doesn't support local queues
581 {
583 }
584
585 FTaskBase::WaitWithNamedThreadsSupport();
586 }
587
593};
594
596template<typename TTask>
597class TGraphTask final : public TConcurrentLinearObject<TGraphTask<TTask>, FTaskGraphBlockAllocationTag>, public FBaseGraphTask
598{
599public:
605 {
606 public:
608
613 template<typename...T>
615 {
616 FGraphEventRef Ref{ ConstructAndHoldImpl(Forward<T>(Args)...) };
617 Ref->TryLaunch(sizeof(TGraphTask));
618 return Ref;
619 }
620
625 template<typename...T>
626 inline TGraphTask* ConstructAndHold(T&&... Args)
627 {
628 TGraphTask* Task = ConstructAndHoldImpl(Forward<T>(Args)...);
629 TaskTrace::Created(Task->GetTraceId(), sizeof(*Task));
630 return Task;
631 }
632
634 : Prerequisites(InPrerequisites)
635 {
636 }
637
638 private:
639 template<typename...T>
640 inline TGraphTask* ConstructAndHoldImpl(T&&... Args)
641 {
642 TGraphTask* Task = new TGraphTask(Prerequisites);
643 TTask* TaskObject = new(&Task->TaskStorage) TTask(Forward<T>(Args)...);
644
645 UE::Tasks::ETaskPriority Pri;
648
649 Task->Init(Pri, ExtPri);
650
651 return Task;
652 }
653
654 private:
655 const FGraphEventArray* Prerequisites;
656 };
657
665 {
666 return FConstructor(Prerequisites);
667 }
668
669private:
672 {
673 }
674
676 {
678 }
679
680 struct CGetStatIdProvider
681 {
682 template <typename TaskType>
683 auto Requires(TaskType& Task) -> decltype(
684 Task.GetStatId()
685 );
686 };
687
688 virtual void ExecuteTask() override final
689 {
690 FGraphEventRef GraphEventRef{ this };
691 TTask* TaskObject = TaskStorage.GetTypedPtr();
692 // Only use this scope when GetStatId() is actually implemented on TaskObject for backward compat, sometimes it's not.
694 {
695 FScopeCycleCounter Scope(TaskObject->GetStatId(), true);
696 TaskObject->DoTask(TaskObject->GetDesiredThread(), GraphEventRef);
697 }
698 else
699 {
700 TaskObject->DoTask(TaskObject->GetDesiredThread(), GraphEventRef);
701 }
703 }
704
705private:
706 TTypeCompatibleBytes<TTask> TaskStorage;
707};
708
709// an adaptation of FBaseGraphTask to be used as a standalone FGraphEvent
711{
712public:
714 : FBaseGraphTask(nullptr)
715 {
716 TaskTrace::Created(GetTraceId(), sizeof(*this));
717 Init(TEXT("GraphEvent"), UE::Tasks::ETaskPriority::Normal, UE::Tasks::EExtendedTaskPriority::TaskEvent);
718 }
719
720 static void* operator new(size_t Size);
721 static void operator delete(void* Ptr);
722
723private:
724 virtual void ExecuteTask() override final
725 {
726 checkNoEntry(); // graph events are never executed
727 }
728};
729
732
733inline void* FGraphEventImpl::operator new(size_t Size)
734{
736}
737
738inline void FGraphEventImpl::operator delete(void* Ptr)
739{
741}
742
744{
745 FGraphEventImpl* GraphEvent = new FGraphEventImpl;
746 return FGraphEventRef{ GraphEvent, /*bAddRef = */ false };
747}
748
749// Blocks the current thread until any of the given tasks is completed.
750// Is slightly more efficient than `AnyTaskCompleted()->Wait()` and supports timeout while `FGraphEvent::Wait()` doesn't.
751// Returns the index of the first completed task, or `INDEX_NONE` on timeout.
753
754// Returns a graph event that gets completed as soon as any of the given tasks gets completed
756
761{
762public:
763
769 : ThreadToReturnFrom(InThreadToReturnFrom)
770 {
771 checkThreadGraph(ThreadToReturnFrom != ENamedThreads::AnyThread); // doesn't make any sense to return from any thread
772 }
773
778
784 {
785 return ThreadToReturnFrom;
786 }
787
789
797 {
798 checkThreadGraph(ENamedThreads::GetThreadIndex(ThreadToReturnFrom) == ENamedThreads::GetThreadIndex(CurrentThread)); // we somehow are executing on the wrong thread.
799 FTaskGraphInterface::Get().RequestReturn(ThreadToReturnFrom);
800 }
801
802private:
804 ENamedThreads::Type ThreadToReturnFrom;
805};
806
812{
813public:
820 {
821#if STATS || ENABLE_STATNAMEDEVENTS
822 StatID = StatId;
823#endif
824 }
825
831 inline TStatId GetStatId() const
832 {
833#if STATS|| ENABLE_STATNAMEDEVENTS
834 return StatID;
835#else
836 return TStatId();
837#endif
838 }
839
840private:
841#if STATS|| ENABLE_STATNAMEDEVENTS
843 TStatId StatID;
844#endif
845
846};
847
852{
853public:
861 , DesiredThread(InDesiredThread)
862 {
863 }
864
870 {
871 return DesiredThread;
872 }
873
875
883 {
884 }
885private:
887 ENamedThreads::Type DesiredThread;
888};
889
894{
895public:
906
911
913 {
914 return DesiredThread;
915 }
916
918
920 {
921 Event->Trigger();
922 }
923private:
924 FEvent* Event;
926 ENamedThreads::Type DesiredThread;
927};
928
931{
932public:
934
936 FDelegate TaskDelegate;
939public:
945
947 {
948 TaskDelegate.ExecuteIfBound();
949 }
962
990};
991
994{
995public:
997
999 FDelegate TaskDelegate;
1002public:
1012 {
1013 TaskDelegate.ExecuteIfBound(CurrentThread, MyCompletionGraphEvent);
1014 }
1027
1057};
1058
1060template<typename Signature, ESubsequentsMode::Type SubsequentsMode>
1062{
1063private:
1067 const ENamedThreads::Type DesiredThread;
1068
1069public:
1081
1083 {
1084 return DesiredThread;
1085 }
1086
1088 {
1089 return SubsequentsMode;
1090 }
1091
1093 {
1094 DoTaskImpl(Function, CurrentThread, MyCompletionGraphEvent);
1095 }
1096
1097private:
1098 UE_FORCEINLINE_HINT static void DoTaskImpl(TUniqueFunction<void()>& Function, ENamedThreads::Type CurrentThread,
1100 {
1101 Function();
1102 }
1103
1104 UE_FORCEINLINE_HINT static void DoTaskImpl(TUniqueFunction<void(const FGraphEventRef&)>& Function,
1106 {
1108 }
1109
1110 UE_FORCEINLINE_HINT static void DoTaskImpl(TUniqueFunction<void(ENamedThreads::Type, const FGraphEventRef&)>& Function,
1112 {
1113 Function(CurrentThread, MyCompletionGraphEvent);
1114 }
1115};
1116
1118{
1119public:
1132
1137
1153
1161};
1162
1163
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define NULL
Definition oodle2base.h:134
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkNoEntry()
Definition AssertionMacros.h:316
#define verify(expr)
Definition AssertionMacros.h:319
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
#define PLATFORM_CACHE_LINE_SIZE
Definition Platform.h:938
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
#define GET_STATID(Stat)
Definition Stats.h:656
#define DECLARE_CYCLE_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:679
#define DECLARE_STATS_GROUP(GroupDesc, GroupId, GroupCat)
Definition Stats.h:689
FORCEINLINE constexpr void DestructItem(ElementType *Element)
Definition MemoryOps.h:56
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void Init()
Definition LockFreeList.h:4
#define DECLARE_INTRINSIC_TYPE_LAYOUT(T)
Definition MemoryLayout.h:760
CORE_API FGraphEventRef AnyTaskCompleted(const FGraphEventArray &GraphEvents)
Definition TaskGraph.cpp:2065
#define checkThreadGraph
Definition TaskGraphInterfaces.h:43
CORE_API FGraphEventImplAllocator & GetGraphEventImplAllocator()
Definition TaskGraph.cpp:1805
TArray< FGraphEventRef, TInlineAllocator< 4 > > FGraphEventArray
Definition TaskGraphInterfaces.h:258
CORE_API TArray< TaskTrace::FId > GetTraceIds(const FGraphEventArray &Tasks)
Definition TaskGraph.cpp:251
CORE_API int32 WaitForAnyTaskCompleted(const FGraphEventArray &GraphEvents, FTimespan Timeout=FTimespan::MaxValue())
Definition TaskGraph.cpp:2060
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition TaskGraphInterfaces.h:213
ENamedThreads::Type Get(ENamedThreads::Type Thread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:228
Definition IConsoleManager.h:1580
Definition TaskGraphInterfaces.h:471
FGraphEventRef GetCompletionEvent()
Definition TaskGraphInterfaces.h:501
ENamedThreads::Type GetThreadToExecuteOn() const
Definition TaskGraphInterfaces.h:589
void Wait(ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:577
void Unlock(ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:547
void Execute(TArray< FBaseGraphTask * > &NewTasks, ENamedThreads::Type CurrentThread, bool bDeleteOnCompletion)
Definition TaskGraphInterfaces.h:490
bool IsTaskEvent() const
Definition TaskGraphInterfaces.h:538
FBaseGraphTask(const FGraphEventArray *InPrerequisites)
Definition TaskGraphInterfaces.h:474
static FGraphEventRef CreateGraphEvent()
Definition TaskGraphInterfaces.h:743
void Init(const TCHAR *InDebugName, UE::Tasks::ETaskPriority InPriority, UE::Tasks::EExtendedTaskPriority InExtendedPriority, UE::Tasks::ETaskFlags InTaskFlags=UE::Tasks::ETaskFlags::None)
Definition TaskGraphInterfaces.h:485
void DispatchSubsequents(ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:559
void DontCompleteUntil(FGraphEventRef NestedTask)
Definition TaskGraphInterfaces.h:510
void SetDebugName(const TCHAR *InDebugName)
Definition TaskGraphInterfaces.h:571
bool IsComplete() const
Definition TaskGraphInterfaces.h:529
Definition TaskGraphInterfaces.h:812
FCustomStatIDGraphTaskBase(const TStatId &StatId)
Definition TaskGraphInterfaces.h:819
TStatId GetStatId() const
Definition TaskGraphInterfaces.h:831
Definition TaskGraphInterfaces.h:994
static FGraphEventRef CreateAndDispatchWhenReady(const FDelegate &InTaskDeletegate, const TStatId InStatId, const FGraphEventRef &InPrerequisite, ENamedThreads::Type InCurrentThreadIfKnown=ENamedThreads::AnyThread, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:1050
DECLARE_DELEGATE_TwoParams(FDelegate, ENamedThreads::Type, const FGraphEventRef &)
FDelegate TaskDelegate
Definition TaskGraphInterfaces.h:999
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef &MyCompletionGraphEvent)
Definition TaskGraphInterfaces.h:1011
static FGraphEventRef CreateAndDispatchWhenReady(const FDelegate &InTaskDeletegate, const TStatId InStatId, const FGraphEventArray *InPrerequisites=NULL, ENamedThreads::Type InCurrentThreadIfKnown=ENamedThreads::AnyThread, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:1037
FDelegateGraphTask(const FDelegate &InTaskDeletegate, const TStatId InStatId, ENamedThreads::Type InDesiredThread)
Definition TaskGraphInterfaces.h:1021
ENamedThreads::Type GetDesiredThread()
Definition TaskGraphInterfaces.h:1003
const ENamedThreads::Type DesiredThread
Definition TaskGraphInterfaces.h:1001
static ESubsequentsMode::Type GetSubsequentsMode()
Definition TaskGraphInterfaces.h:1007
Definition Event.h:21
virtual void Trigger()=0
Definition TaskGraphInterfaces.h:711
FGraphEventImpl()
Definition TaskGraphInterfaces.h:713
Definition TaskGraphInterfaces.h:852
FNullGraphTask(const TStatId &StatId, ENamedThreads::Type InDesiredThread)
Definition TaskGraphInterfaces.h:859
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef &MyCompletionGraphEvent)
Definition TaskGraphInterfaces.h:882
ENamedThreads::Type GetDesiredThread()
Definition TaskGraphInterfaces.h:869
static ESubsequentsMode::Type GetSubsequentsMode()
Definition TaskGraphInterfaces.h:874
Definition TaskGraphInterfaces.h:761
ENamedThreads::Type GetDesiredThread()
Definition TaskGraphInterfaces.h:783
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef &MyCompletionGraphEvent)
Definition TaskGraphInterfaces.h:796
UE_FORCEINLINE_HINT TStatId GetStatId() const
Definition TaskGraphInterfaces.h:774
static ESubsequentsMode::Type GetSubsequentsMode()
Definition TaskGraphInterfaces.h:788
FReturnGraphTask(ENamedThreads::Type InThreadToReturnFrom)
Definition TaskGraphInterfaces.h:768
Definition LightweightStats.h:424
Definition TaskGraphInterfaces.h:931
static FGraphEventRef CreateAndDispatchWhenReady(const FDelegate &InTaskDeletegate, const TStatId InStatId, const FGraphEventArray *InPrerequisites=NULL, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:971
const ENamedThreads::Type DesiredThread
Definition TaskGraphInterfaces.h:938
static FGraphEventRef CreateAndDispatchWhenReady(const FDelegate &InTaskDeletegate, const TStatId &&InStatId, const FGraphEventRef &InPrerequisite, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:983
FDelegate TaskDelegate
Definition TaskGraphInterfaces.h:936
FSimpleDelegateGraphTask(const FDelegate &InTaskDeletegate, const TStatId StatId, ENamedThreads::Type InDesiredThread)
Definition TaskGraphInterfaces.h:956
ENamedThreads::Type GetDesiredThread()
Definition TaskGraphInterfaces.h:940
static ESubsequentsMode::Type GetSubsequentsMode()
Definition TaskGraphInterfaces.h:944
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef &MyCompletionGraphEvent)
Definition TaskGraphInterfaces.h:946
Definition TaskGraphInterfaces.h:265
virtual void AttachToThread(ENamedThreads::Type CurrentThread)=0
virtual void RequestReturn(ENamedThreads::Type CurrentThread)=0
virtual int32 GetNumBackgroundThreads()=0
static CORE_API void Shutdown()
Definition TaskGraph.cpp:1783
virtual void TriggerEventWhenTasksComplete(FEvent *InEvent, const FGraphEventArray &Tasks, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread, ENamedThreads::Type TriggerThread=ENamedThreads::AnyHiPriThreadHiPriTask)=0
virtual bool IsThreadProcessingTasks(ENamedThreads::Type ThreadToCheck)=0
TFunction< EProcessTasksOperation(int32)> FProcessTasksUpdateCallback
Definition TaskGraphInterfaces.h:391
virtual bool IsCurrentThreadKnown()=0
virtual void ProcessThreadUntilRequestReturn(ENamedThreads::Type CurrentThread)=0
static CORE_API bool IsRunning()
Definition TaskGraph.cpp:1789
void WaitUntilTaskCompletes(FGraphEventRef &&Task, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:421
static CORE_API FTaskGraphInterface & Get()
Definition TaskGraph.cpp:1794
void TriggerEventWhenTaskCompletes(FEvent *InEvent, const FGraphEventRef &Task, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread, ENamedThreads::Type TriggerThread=ENamedThreads::AnyHiPriThreadHiPriTask)
Definition TaskGraphInterfaces.h:432
static CORE_API void Startup(int32 NumThreads)
Definition TaskGraph.cpp:1760
virtual void WakeNamedThread(ENamedThreads::Type ThreadToWake)=0
void WaitUntilTaskCompletes(const FGraphEventRef &Task, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:416
virtual void StallForTuning(int32 Index, bool Stall)=0
EProcessTasksOperation
Definition TaskGraphInterfaces.h:373
virtual int32 GetNumForegroundThreads()=0
virtual int32 GetNumWorkerThreads()=0
virtual ENamedThreads::Type GetCurrentThreadIfKnown(bool bLocalQueue=false)=0
virtual bool ProcessUntilTasksComplete(const FGraphEventArray &Tasks, ENamedThreads::Type CurrentThreadIfKnown, const FProcessTasksUpdateCallback &IdleWorkUpdate={})=0
static bool IsMultithread()
Definition TaskGraph.cpp:1800
static void BroadcastSlow_OnlyUseForSpecialPurposes(bool bDoTaskThreads, bool bDoBackgroundThreads, TFunction< void(ENamedThreads::Type CurrentThread)> &Callback)
Definition TaskGraph.cpp:1897
virtual FBaseGraphTask * FindWork(ENamedThreads::Type ThreadInNeed)=0
virtual uint64 ProcessThreadUntilIdle(ENamedThreads::Type CurrentThread)=0
virtual void WaitUntilTasksComplete(const FGraphEventArray &Tasks, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)=0
virtual ~FTaskGraphInterface()
Definition TaskGraphInterfaces.h:279
virtual void AddShutdownCallback(TFunction< void()> &Callback)=0
Definition TaskGraphInterfaces.h:894
UE_FORCEINLINE_HINT TStatId GetStatId() const
Definition TaskGraphInterfaces.h:907
ENamedThreads::Type GetDesiredThread()
Definition TaskGraphInterfaces.h:912
static ESubsequentsMode::Type GetSubsequentsMode()
Definition TaskGraphInterfaces.h:917
FTriggerEventGraphTask(FEvent *InEvent, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyHiPriThreadHiPriTask)
Definition TaskGraphInterfaces.h:900
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef &MyCompletionGraphEvent)
Definition TaskGraphInterfaces.h:919
Definition IConsoleManager.h:558
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition Atomic.h:538
Definition ConcurrentLinearAllocator.h:65
Definition ConcurrentLinearAllocator.h:571
Definition TaskGraphInterfaces.h:1062
ENamedThreads::Type GetDesiredThread() const
Definition TaskGraphInterfaces.h:1082
TFunctionGraphTaskImpl(TUniqueFunction< Signature > &&InFunction, TStatId StatId, ENamedThreads::Type InDesiredThread)
Definition TaskGraphInterfaces.h:1076
static ESubsequentsMode::Type GetSubsequentsMode()
Definition TaskGraphInterfaces.h:1087
UE_FORCEINLINE_HINT void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef &MyCompletionGraphEvent)
Definition TaskGraphInterfaces.h:1092
Definition AndroidPlatformMisc.h:14
Definition TaskGraphInterfaces.h:605
TGraphTask * ConstructAndHold(T &&... Args)
Definition TaskGraphInterfaces.h:626
FGraphEventRef ConstructAndDispatchWhenReady(T &&... Args)
Definition TaskGraphInterfaces.h:614
FConstructor(const FGraphEventArray *InPrerequisites)
Definition TaskGraphInterfaces.h:633
UE_NONCOPYABLE(FConstructor)
Definition TaskGraphInterfaces.h:598
static FConstructor CreateTask(const FGraphEventArray *Prerequisites=nullptr, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:664
void * Allocate()
Definition LockFreeFixedSizeAllocator.h:51
void Free(void *Item)
Definition LockFreeFixedSizeAllocator.h:100
Definition LockFreeFixedSizeAllocator.h:334
Definition FunctionFwd.h:19
Definition TaskPrivate.h:120
bool IsNamedThreadTask() const
Definition TaskPrivate.h:205
EExtendedTaskPriority GetExtendedPriority() const
Definition TaskPrivate.h:215
void AddNested(FTaskBase &Nested)
Definition TaskPrivate.h:444
bool AddPrerequisites(FTaskBase &Prerequisite)
Definition TaskPrivate.h:223
void AddRef()
Definition TaskPrivate.h:131
bool TryExecuteTask()
Definition TaskPrivate.h:492
TaskTrace::FId GetTraceId() const
Definition TaskPrivate.h:479
void UnlockPrerequisites()
Definition TaskPrivate.h:825
bool TryLaunch(uint64 TaskSize)
Definition TaskPrivate.h:409
void ReleaseInternalReference()
Definition TaskPrivate.h:438
FTaskBase(uint32 InitRefCount, bool bUnlockPrerequisites=true)
Definition TaskPrivate.h:157
bool IsCompleted() const
Definition TaskPrivate.h:424
ETaskPriority GetPriority() const
Definition TaskPrivate.h:210
Definition TaskGraph.cpp:63
CORE_API int32 bHasBackgroundThreads
Definition TaskGraph.cpp:66
UE_FORCEINLINE_HINT Type GetRenderThread()
Definition TaskGraphInterfaces.h:123
UE_FORCEINLINE_HINT Type GetThreadIndex(Type ThreadAndIndex)
Definition TaskGraphInterfaces.h:148
UE_FORCEINLINE_HINT void SetRenderThread_Local(Type Thread)
Definition TaskGraphInterfaces.h:138
int32 GetThreadPriorityIndex(Type ThreadAndIndex)
Definition TaskGraphInterfaces.h:163
Type SetPriorities(Type ThreadAndIndex, Type ThreadPriority, Type TaskPriority)
Definition TaskGraphInterfaces.h:170
UE_FORCEINLINE_HINT void SetRenderThread(Type Thread)
Definition TaskGraphInterfaces.h:133
Type SetThreadPriority(Type ThreadAndIndex, Type ThreadPriority)
Definition TaskGraphInterfaces.h:190
UE_FORCEINLINE_HINT int32 GetQueueIndex(Type ThreadAndIndex)
Definition TaskGraphInterfaces.h:153
CORE_API int32 bHasHighPriorityThreads
Definition TaskGraph.cpp:67
Type SetTaskPriority(Type ThreadAndIndex, Type TaskPriority)
Definition TaskGraphInterfaces.h:200
UE_FORCEINLINE_HINT int32 GetTaskPriority(Type ThreadAndIndex)
Definition TaskGraphInterfaces.h:158
Type
Definition TaskGraphInterfaces.h:57
@ QueueIndexShift
Definition TaskGraphInterfaces.h:77
@ NumThreadPriorities
Definition TaskGraphInterfaces.h:92
@ NormalTaskPriority
Definition TaskGraphInterfaces.h:81
@ NumTaskPriorities
Definition TaskGraphInterfaces.h:84
@ BackgroundThreadPriority
Definition TaskGraphInterfaces.h:90
@ NormalThreadPriority
Definition TaskGraphInterfaces.h:88
@ TaskPriorityMask
Definition TaskGraphInterfaces.h:85
@ RHIThread
Definition TaskGraphInterfaces.h:60
@ GameThread
Definition TaskGraphInterfaces.h:61
@ HighThreadPriority
Definition TaskGraphInterfaces.h:89
@ ThreadIndexMask
Definition TaskGraphInterfaces.h:75
@ UnusedAnchor
Definition TaskGraphInterfaces.h:58
@ NumQueues
Definition TaskGraphInterfaces.h:74
@ AnyBackgroundThreadNormalTask
Definition TaskGraphInterfaces.h:106
@ ThreadPriorityShift
Definition TaskGraphInterfaces.h:94
@ QueueIndexMask
Definition TaskGraphInterfaces.h:76
@ ThreadPriorityMask
Definition TaskGraphInterfaces.h:93
@ ActualRenderingThread
Definition TaskGraphInterfaces.h:63
@ AnyHiPriThreadHiPriTask
Definition TaskGraphInterfaces.h:101
@ HighTaskPriority
Definition TaskGraphInterfaces.h:82
@ AnyNormalThreadHiPriTask
Definition TaskGraphInterfaces.h:104
@ LocalQueue
Definition TaskGraphInterfaces.h:72
@ AnyHiPriThreadNormalTask
Definition TaskGraphInterfaces.h:100
@ ActualRenderingThread_Local
Definition TaskGraphInterfaces.h:98
@ AnyBackgroundHiPriTask
Definition TaskGraphInterfaces.h:107
@ AnyNormalThreadNormalTask
Definition TaskGraphInterfaces.h:103
@ TaskPriorityShift
Definition TaskGraphInterfaces.h:86
@ GameThread_Local
Definition TaskGraphInterfaces.h:97
@ AnyThread
Definition TaskGraphInterfaces.h:67
@ MainQueue
Definition TaskGraphInterfaces.h:71
UE_FORCEINLINE_HINT Type GetRenderThread_Local()
Definition TaskGraphInterfaces.h:128
Definition TaskGraphInterfaces.h:247
Type
Definition TaskGraphInterfaces.h:249
@ FireAndForget
Definition TaskGraphInterfaces.h:253
@ TrackSubsequents
Definition TaskGraphInterfaces.h:251
void TASK_CORE_API Created(FId TaskId, uint64 TaskSize)
Definition TaskTrace.h:76
ENamedThreads::Type TranslatePriority(EExtendedTaskPriority Priority)
Definition TaskPrivate.cpp:502
FTaskBase * GetCurrentTask()
Definition TaskPrivate.cpp:288
ETaskFlags
Definition TaskPrivate.h:89
EExtendedTaskPriority
Definition TaskPrivate.h:60
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition TaskGraphInterfaces.h:111
friend void SetRenderThread(Type Thread)
Definition TaskGraphInterfaces.h:133
friend void SetRenderThread_Local(Type Thread)
Definition TaskGraphInterfaces.h:138
friend Type GetRenderThread()
Definition TaskGraphInterfaces.h:123
friend Type GetRenderThread_Local()
Definition TaskGraphInterfaces.h:128
Definition ConcurrentLinearAllocator.h:154
Definition TaskGraphInterfaces.h:1118
static FGraphEventRef CreateAndDispatchWhenReady(TUniqueFunction< void()> InFunction, TStatId InStatId, const FGraphEventRef &InPrerequisite, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:1146
static FGraphEventRef CreateAndDispatchWhenReady(TUniqueFunction< void(ENamedThreads::Type, const FGraphEventRef &)> InFunction, TStatId InStatId, const FGraphEventRef &InPrerequisite, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:1154
static FGraphEventRef CreateAndDispatchWhenReady(TUniqueFunction< void()> InFunction, TStatId InStatId=TStatId{}, const FGraphEventArray *InPrerequisites=nullptr, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:1128
static FGraphEventRef CreateAndDispatchWhenReady(TUniqueFunction< void(ENamedThreads::Type, const FGraphEventRef &)> InFunction, TStatId InStatId=TStatId{}, const FGraphEventArray *InPrerequisites=nullptr, ENamedThreads::Type InDesiredThread=ENamedThreads::AnyThread)
Definition TaskGraphInterfaces.h:1133
Definition TaskGraphInterfaces.h:459
static constexpr bool InlineBlockAllocation
Definition TaskGraphInterfaces.h:463
static constexpr uint32 BlockSize
Definition TaskGraphInterfaces.h:460
static constexpr bool RequiresAccurateSize
Definition TaskGraphInterfaces.h:462
static constexpr const char * TagName
Definition TaskGraphInterfaces.h:464
static constexpr bool AllowOversizedBlocks
Definition TaskGraphInterfaces.h:461
Definition Timespan.h:76
static FTimespan MaxValue()
Definition Timespan.h:686
Definition LightweightStats.h:416
Definition TypeCompatibleBytes.h:24
ElementType * GetTypedPtr()
Definition TypeCompatibleBytes.h:38