Plasma Engine  2.0
Loading...
Searching...
No Matches
TaskGroup.h
1#pragma once
2
3#include <Foundation/Strings/String.h>
4#include <Foundation/Threading/AtomicInteger.h>
5#include <Foundation/Threading/ConditionVariable.h>
6#include <Foundation/Threading/Implementation/TaskSystemDeclarations.h>
7#include <Foundation/Types/SharedPtr.h>
8
11{
12 PL_DISALLOW_COPY_AND_ASSIGN(plTaskGroup);
13
14public:
17
18private:
19 friend class plTaskSystem;
20
21#if PL_ENABLED(PL_COMPILE_FOR_DEBUG)
22 static void DebugCheckTaskGroup(plTaskGroupID groupID, plMutex& mutex);
23#else
24 PL_ALWAYS_INLINE static void DebugCheckTaskGroup(plTaskGroupID groupID, plMutex& mutex)
25 {
26 }
27#endif
28
30 void WaitForFinish(plTaskGroupID group) const;
31 void Reuse(plTaskPriority::Enum priority, plOnTaskGroupFinishedCallback callback);
32
33 bool m_bInUse = true;
34 bool m_bStartedByUser = false;
35 plUInt16 m_uiTaskGroupIndex = 0xFFFF; // only there as a debugging aid
36 plUInt32 m_uiGroupCounter = 1;
38 plHybridArray<plTaskGroupID, 4> m_DependsOnGroups;
39 plHybridArray<plTaskGroupID, 8> m_OthersDependingOnMe;
40 plAtomicInteger32 m_iNumActiveDependencies;
41 plAtomicInteger32 m_iNumRemainingTasks;
42 plOnTaskGroupFinishedCallback m_OnFinishedCallback;
44 mutable plConditionVariable m_CondVarGroupFinished;
45};
Condition variables are used to put threads to sleep and wake them up upon certain events.
Definition ConditionVariable.h:22
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
Definition TaskGroup.h:11
Given out by plTaskSystem::CreateTaskGroup to identify a task group.
Definition TaskSystemDeclarations.h:103
This system allows to automatically distribute tasks onto a number of worker threads.
Definition TaskSystem.h:25
Enum
Definition TaskSystemDeclarations.h:41
@ ThisFrame
Medium priority, guaranteed to get finished in this frame.
Definition TaskSystemDeclarations.h:43