Loading...
Searching...
No Matches
parallelTaskWaitlist.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_VDF_PARALLEL_TASK_WAITLIST_H
8#define PXR_EXEC_VDF_PARALLEL_TASK_WAITLIST_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/api.h"
15
16#include "pxr/base/work/taskGraph.h"
17
18#include <tbb/concurrent_vector.h>
19
20#include <atomic>
21
22PXR_NAMESPACE_OPEN_SCOPE
23
44{
45public:
48 struct Node;
52 using HeadPtr = std::atomic<Node*>;
53
58 delete;
59
66 VDF_API
67 explicit VdfParallelTaskWaitlist(size_t numReserved = 0);
68
71 VDF_API
73
77 VDF_API
78 void Rewind();
79
85 VDF_API
86 bool WaitOn(HeadPtr *headPtr, WorkTaskGraph::BaseTask *successor);
87
92 VDF_API
93 bool CloseAndNotify(HeadPtr *headPtr, WorkTaskGraph *taskGraph);
94
95private:
96 // Allocate a new node for a waiting queue.
97 //
98 VDF_API
99 Node *_AllocateNode(WorkTaskGraph::BaseTask *task, Node *next);
100
101 // A simple vector that serves as a way of scratch-allocating new
102 // waiting nodes.
103 //
104 tbb::concurrent_vector<Node> _allocator;
105};
106
107PXR_NAMESPACE_CLOSE_SCOPE
108
109#endif
VdfParallelTaskWaitlist.
VDF_API bool WaitOn(HeadPtr *headPtr, WorkTaskGraph::BaseTask *successor)
Registers successor as waiting on the list denoted by headPtr.
VDF_API VdfParallelTaskWaitlist(size_t numReserved=0)
Constructor.
std::atomic< Node * > HeadPtr
This type denotes the head of an independent waitlist.
VDF_API bool CloseAndNotify(HeadPtr *headPtr, WorkTaskGraph *taskGraph)
Closes the list denoted by headPtr, and notifies any tasks that are waiting on this list.
VDF_API void Rewind()
Rewind the internal state and ensure that internally allocated memory does not grow beyond this point...
VdfParallelTaskWaitlist(const VdfParallelTaskWaitlist &)=delete
Noncopyable.
VDF_API ~VdfParallelTaskWaitlist()
Destructor.
Base class for a parallel task that emulates tbb::task (deprecated in the oneTBB version upgrade....
Definition: taskGraph.h:106
Instances of this class are used to spawn and wait on a directed graph of tasks, where tasks preserve...
Definition: taskGraph.h:37