![]() |
|
VdfParallelTaskWaitlist. More...
#include <parallelTaskWaitlist.h>
Public Types | |
| using | HeadPtr = std::atomic< Node * > |
| This type denotes the head of an independent waitlist. | |
Public Member Functions | |
| VdfParallelTaskWaitlist (const VdfParallelTaskWaitlist &)=delete | |
| Noncopyable. | |
| VdfParallelTaskWaitlist & | operator= (const VdfParallelTaskWaitlist &)=delete |
| VDF_API | VdfParallelTaskWaitlist (size_t numReserved=0) |
| Constructor. | |
| VDF_API | ~VdfParallelTaskWaitlist () |
| Destructor. | |
| VDF_API void | Rewind () |
| Rewind the internal state and ensure that internally allocated memory does not grow beyond this point. | |
| 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. | |
This class manages lists of tasks waiting on uncompleted work. One instance of this class can manage multiple independent queues denoted by separate VdfParallelTaskWaitlist::HeadPtr instances.
The client is expected to instantiate one or more heads, and then use the methods WaitOn(), to wait on completion of the work denoted by those heads respectively. Once the work has been completed, CloseAndNotify() can be called to close the waiting list denoted by the respective head, and simultanously notify all the currently waiting tasks to continue their execution - assuming their task reference count reaches 0. Tasks with reference counts greater than 0 are still waiting on other, unfulfilled dependencies.
The client is expected to call Rewind() once all heads have been closed and notified. This ensures that the internal state of this class has been reset, and its allocated memory does not grow past invocations of Rewind().
Definition at line 43 of file parallelTaskWaitlist.h.
| using HeadPtr = std::atomic<Node*> |
This type denotes the head of an independent waitlist.
Clients are expected to instantiate this one of these for each independent list.
Definition at line 52 of file parallelTaskWaitlist.h.
|
delete |
Noncopyable.
|
explicit |
Constructor.
Reserves numReserved waiting nodes as an optimization that can eliminate many smaller allocations for when the approximate size of the waiting lists is known ahead of time.
| VDF_API ~VdfParallelTaskWaitlist | ( | ) |
Destructor.
| VDF_API bool CloseAndNotify | ( | HeadPtr * | headPtr, |
| WorkTaskGraph * | taskGraph | ||
| ) |
Closes the list denoted by headPtr, and notifies any tasks that are waiting on this list.
Returns false if the list had already been closed prior to calling CloseAndNotify().
| VDF_API void Rewind | ( | ) |
Rewind the internal state and ensure that internally allocated memory does not grow beyond this point.
| VDF_API bool WaitOn | ( | HeadPtr * | headPtr, |
| WorkTaskGraph::BaseTask * | successor | ||
| ) |
Registers successor as waiting on the list denoted by headPtr.
The method will return false if the list is already closed and successor does not need to wait. Returns true if the successor is now successfully waiting for the list to be closed.