UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TaskShared.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
9
10namespace LowLevelTasks {
11
13
14template<typename NodeType>
15using TAlignedArray = TArray<NodeType, TAlignedHeapAllocator<alignof(NodeType)>>;
16
17namespace Private {
18
20{
21private:
22 bool ActivelyLookingForWork = false;
23
24#if CPUPROFILERTRACE_ENABLED
25 bool bCpuBeginEventEmitted = false;
26#endif
27public:
28 inline ~FOutOfWork()
29 {
30 Stop();
31 }
32
33 inline bool Start()
34 {
35 if (!ActivelyLookingForWork)
36 {
37#if CPUPROFILERTRACE_ENABLED
38 if (CpuChannel)
39 {
40 static uint32 WorkerLookingForWorkTraceId = FCpuProfilerTrace::OutputEventType("TaskWorkerIsLookingForWork");
41 FCpuProfilerTrace::OutputBeginEvent(WorkerLookingForWorkTraceId);
42 bCpuBeginEventEmitted = true;
43 }
44#endif
45 ActivelyLookingForWork = true;
46 return true;
47 }
48 return false;
49 }
50
51 inline bool Stop()
52 {
53 if (ActivelyLookingForWork)
54 {
55#if CPUPROFILERTRACE_ENABLED
56 if (bCpuBeginEventEmitted)
57 {
58 FCpuProfilerTrace::OutputEndEvent();
59 bCpuBeginEventEmitted = false;
60 }
61#endif
62 ActivelyLookingForWork = false;
63 return true;
64 }
65 return false;
66 }
67};
68
69} // namespace Private
70
71} // namespace LowLevelTasks
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_TS_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:26
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition TaskShared.h:20
bool Stop()
Definition TaskShared.h:51
~FOutOfWork()
Definition TaskShared.h:28
bool Start()
Definition TaskShared.h:33
Definition ContainerAllocationPolicies.h:447
Definition Array.h:670
Definition Scheduler.cpp:25
Definition OverriddenPropertySet.cpp:45