Default implementation of WorkUnit. This represents on piece of work through time. More...
#include <workunit.h>
Public Member Functions | |
DefaultWorkUnit () | |
Simple constructor. | |
virtual | ~DefaultWorkUnit () |
Virtual destructor, doesn't actually do much. | |
virtual void | AddDependency (iWorkUnit *NewDependency) |
Force this WorkUnit to Start after another has completed. More... | |
virtual void | ClearDependencies () |
Drop any information about what work units this one depends on. | |
virtual iWorkUnit * | GetDependency (Whole Index) const |
This is used to iterate of all the dependencies. More... | |
virtual Whole | GetDependencyCount () const |
How many other WorkUnits does this one depend on? More... | |
virtual Whole | GetDependentCount (FrameScheduler &SchedulerToCount) |
This returns the count workunits that depend on this work unit. More... | |
virtual Whole | GetImmediateDependencyCount () const |
Get the amount of dependencies that directly count on this for access purposes. More... | |
virtual Whole | GetPerformance () const |
Get the internal rolling average for querying. More... | |
virtual RollingAverage< Whole > & | GetPerformanceLog () |
Get the internal rolling average for querying. More... | |
virtual RunningState | GetRunningState () const |
Retrieves the current RunningState of the thread. More... | |
virtual WorkUnitKey | GetSortingKey (FrameScheduler &SchedulerToCount) |
Get the sorting metadata. More... | |
virtual bool | IsEveryDependencyComplete () |
Check if this WorkUnit could concievably run right now. More... | |
virtual void | operator() (DefaultThreadSpecificStorage::Type &CurrentThreadStorage) |
This does everything required to track metadata and log work. More... | |
virtual void | PrepareForNextFrame () |
This resets the running state and takes any further action required to use the WorkUnit again. | |
virtual void | RemoveDependency (iWorkUnit *RemoveDependency) |
Remove a dependency. More... | |
virtual RunningState | TakeOwnerShip () |
Attempts to atomically start the work unit in the current thread. More... | |
Public Member Functions inherited from Mezzanine::Threading::iWorkUnit | |
virtual | ~iWorkUnit () |
Virtual destructor. | |
virtual void | DoWork (DefaultThreadSpecificStorage::Type &CurrentThreadStorage)=0 |
WorkUnits Must implement these to do the work. | |
Protected Attributes | |
Int32 | CurrentRunningState |
This controls do work with this after it has. | |
std::vector< iWorkUnit * > | Dependencies |
A collection of of workunits that must be complete before this one can start. | |
DefaultRollingAverage< Whole >::Type | PerformanceLog |
A rolling average of execution times. | |
Default implementation of WorkUnit. This represents on piece of work through time.
Definition at line 160 of file workunit.h.
|
virtual |
Force this WorkUnit to Start after another has completed.
NewDependency | The WorkUnit that must start after this one has completed. |
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 99 of file workunit.cpp.
This is used to iterate of all the dependencies.
Index | The 0 based index of the dependency you are trying to retrieve. No ordering is guaranteed, just that counting from 0 to GetImmediateDependencyCount() with access each iWorkUnit once. |
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 84 of file workunit.cpp.
|
virtual |
How many other WorkUnits does this one depend on?
This is what the FrameScheduler uses to calculate the sorting order of WorkUnits. In the default implmentation it counts some units twice if they depend on this WorkUnit through Multiple dependency chains.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 90 of file workunit.cpp.
|
virtual |
This returns the count workunits that depend on this work unit.
SchedulerToCount | The FrameScheduler has a cache of this data, it is impossible to calculate without the complete list of WorkUnits on it either. |
Because Dependents are not tracked this iterates over entry in the FrameScheduler it is passed.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 78 of file workunit.cpp.
|
virtual |
Get the amount of dependencies that directly count on this for access purposes.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 87 of file workunit.cpp.
|
virtual |
Get the internal rolling average for querying.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 145 of file workunit.cpp.
|
virtual |
Get the internal rolling average for querying.
Definition at line 148 of file workunit.cpp.
|
virtual |
Retrieves the current RunningState of the thread.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 136 of file workunit.cpp.
|
virtual |
Get the sorting metadata.
SchedulerToCount | This uses the metadata on the FrameScheduler to generate the Dependency listing required. |
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 175 of file workunit.cpp.
|
virtual |
Check if this WorkUnit could concievably run right now.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 113 of file workunit.cpp.
|
virtual |
This does everything required to track metadata and log work.
CurrentThreadStorage | The FrameScheduler passes this in |
This wraps the log output in a WorkUnit element with a unique ID as and an attribute. This causes all the log output to be valid xml as long no '<' or '>' are emitted.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 154 of file workunit.cpp.
|
virtual |
Remove a dependency.
RemoveDependency | A pointer to the WorkUnit to remove as a dependency. |
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 102 of file workunit.cpp.
|
virtual |
Attempts to atomically start the work unit in the current thread.
Implements Mezzanine::Threading::iWorkUnit.
Definition at line 125 of file workunit.cpp.