16namespace ph {
class FixedSizeThreadPool; }
24 using Work = std::function<void()>;
40 template<std::
size_t N>
41 void runsBefore(std::array<WorkHandle, N> succeedingWorks);
43 template<std::
size_t N>
44 void runsAfter(std::array<WorkHandle, N> preceedingWorks);
49 operator bool ()
const;
60 explicit Workflow(std::size_t numExpectedWorks);
65 template<
typename... WorkTypes>
74 class ManagedWork final
85 void ensureValidWorkHandle(WorkHandle work)
const;
87 void finishWorkflow();
88 std::unique_ptr<std::size_t[]> determineDispatchOrderFromTopologicalSort()
const;
90 std::vector<Work> m_works;
96 std::vector<std::vector<std::size_t>> m_idToDependencyIds;
98 std::unique_ptr<std::atomic_flag[]> m_workDoneFlags;
103template<
typename... WorkTypes>
106 return std::array{
addWork(std::forward<WorkTypes>(works))...};
125template<std::
size_t N>
131template<std::
size_t N>
147inline Workflow::WorkHandle::operator bool ()
const
149 return m_workId !=
static_cast<std::size_t
>(-1) && m_workflow !=
nullptr;
A thread pool where works are accessed concurrently by blocking other threads. A thread pool that con...
Definition FixedSizeThreadPool.h:21
Marks the derived class as non-copyable and non-movable.
Definition INoCopyAndMove.h:17
Lightweight handle for an added work.
Definition Workflow.h:29
WorkHandle()
Definition Workflow.cpp:17
std::size_t getWorkId() const
Definition Workflow.h:137
void runsAfter(WorkHandle preceedingWork)
Definition Workflow.cpp:31
Workflow * getWorkflow() const
Definition Workflow.h:142
void runsBefore(WorkHandle succeedingWork)
Definition Workflow.cpp:25
Workflow()
Definition Workflow.cpp:70
WorkHandle acquireWork(std::size_t workIndex)
Definition Workflow.cpp:95
void dependsOn(WorkHandle target, WorkHandle targetDependency)
Definition Workflow.cpp:107
WorkHandle addWork(Work work)
Definition Workflow.cpp:81
std::size_t numWorks() const
Definition Workflow.cpp:141
auto addWorks(WorkTypes &&... works)
Definition Workflow.h:104
std::function< void()> Work
Definition Workflow.h:24
void runAndWaitAllWorks(FixedSizeThreadPool &workers)
Definition Workflow.cpp:116
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< const T, EXTENT > TSpanView
Same as TSpan, except that the objects are const-qualified. Note that for pointer types,...
Definition TSpan.h:19