7#ifndef PXR_EXEC_VDF_PARALLEL_TASK_SYNC_H
8#define PXR_EXEC_VDF_PARALLEL_TASK_SYNC_H
14#include "pxr/exec/vdf/api.h"
17#include "pxr/base/work/taskGraph.h"
23PXR_NAMESPACE_OPEN_SCOPE
47 , _taskGraph(taskGraph)
85 inline void MarkDone(
const size_t idx);
90 enum _TaskState : uint8_t {
97 std::unique_ptr<std::atomic<uint8_t>[]> _state;
100 std::unique_ptr<VdfParallelTaskWaitlist::HeadPtr[]> _waiting;
119 uint8_t state = _state[idx].load(std::memory_order_acquire);
122 if (state == _TaskStateDone) {
128 else if (state == _TaskStateUnclaimed &&
129 _state[idx].compare_exchange_strong(state, _TaskStateClaimed)) {
135 return _waitlists.
WaitOn(&_waiting[idx], successor)
144 _state[idx].store(_TaskStateDone, std::memory_order_release);
150PXR_NAMESPACE_CLOSE_SCOPE
Instances of this class are used to synchronize dynamic, acyclic task graphs, allowing tasks to claim...
VdfParallelTaskSync(const VdfParallelTaskSync &)=delete
Noncopyable.
State
The different states a task can be in.
@ Wait
The task is already done.
@ Claimed
The task is currently running, the claimant must wait for the task to complete.
VDF_API void Reset(const size_t num)
Resets the state of all tasks in the graph.
VdfParallelTaskSync(WorkTaskGraph *taskGraph)
Constructor.
State Claim(const size_t idx, WorkTaskGraph::BaseTask *successor)
Claims the task idx for processing, and returns the new task state.
void MarkDone(const size_t idx)
Mark the task idx as done.
VDF_API bool WaitOn(HeadPtr *headPtr, WorkTaskGraph::BaseTask *successor)
Registers successor as waiting on the list denoted by headPtr.
VDF_API bool CloseAndNotify(HeadPtr *headPtr, WorkTaskGraph *taskGraph)
Closes the list denoted by headPtr, and notifies any tasks that are waiting on this list.
Base class for a parallel task that emulates tbb::task (deprecated in the oneTBB version upgrade....
Instances of this class are used to spawn and wait on a directed graph of tasks, where tasks preserve...