Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | List of all members
Mezzanine::Threading::iWorkUnit Class Referenceabstract

Interface of a WorkUnit. This represents on piece of work through time. More...

#include <workunit.h>

+ Inheritance diagram for Mezzanine::Threading::iWorkUnit:

Public Member Functions

virtual ~iWorkUnit ()
 Virtual destructor.
 
virtual void AddDependency (iWorkUnit *NewDependency)=0
 Force this WorkUnit to Start after another has completed. More...
 
virtual void ClearDependencies ()=0
 Drop any information about what work units this one depends on.
 
virtual void DoWork (DefaultThreadSpecificStorage::Type &CurrentThreadStorage)=0
 WorkUnits Must implement these to do the work.
 
virtual iWorkUnitGetDependency (Whole Index) const =0
 This is used to iterate of all the dependencies. More...
 
virtual Whole GetDependencyCount () const =0
 How many other WorkUnits does this one depend on? More...
 
virtual Whole GetDependentCount (FrameScheduler &SchedulerToCount)=0
 This returns the count workunits that depend on this work unit. More...
 
virtual Whole GetImmediateDependencyCount () const =0
 Get the amount of dependencies that directly count on this for access purposes. More...
 
virtual Whole GetPerformance () const =0
 Get the internal rolling average for querying. More...
 
virtual RunningState GetRunningState () const =0
 Retrieves the current RunningState of the thread. More...
 
virtual WorkUnitKey GetSortingKey (FrameScheduler &SchedulerToCount)=0
 Get the sorting metadata. More...
 
virtual bool IsEveryDependencyComplete ()=0
 Check if this WorkUnit could concievably run right now. More...
 
virtual void operator() (DefaultThreadSpecificStorage::Type &CurrentThreadStorage)=0
 This tracks work unit metadata, then calls DoWork. More...
 
virtual void PrepareForNextFrame ()=0
 This resets the running state and takes any further action required to use the WorkUnit again.
 
virtual void RemoveDependency (iWorkUnit *RemoveDependency)=0
 Remove a dependency. More...
 
virtual RunningState TakeOwnerShip ()=0
 Attempts to atomically start the work unit in the current thread. More...
 

Detailed Description

Interface of a WorkUnit. This represents on piece of work through time.

This has no real substance, use the DefaultWorkUnit class is you want to inherit from something ready for easy integration. Implement this if you want to make heavy changes to the algorithm or maximize performance.

Definition at line 66 of file workunit.h.

Member Function Documentation

virtual void Mezzanine::Threading::iWorkUnit::AddDependency ( iWorkUnit NewDependency)
pure virtual

Force this WorkUnit to Start after another has completed.

Parameters
NewDependencyThe WorkUnit that must start after this one has completed.
Warning
Changing this outside the schedule, once the scheduler has started can cause undefined behavior.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual iWorkUnit* Mezzanine::Threading::iWorkUnit::GetDependency ( Whole  Index) const
pure virtual

This is used to iterate of all the dependencies.

Parameters
IndexThe 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.
Returns
A pointer to an iWorkUnit.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual Whole Mezzanine::Threading::iWorkUnit::GetDependencyCount ( ) const
pure 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.

Returns
A Whole containing the answer.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual Whole Mezzanine::Threading::iWorkUnit::GetDependentCount ( FrameScheduler SchedulerToCount)
pure virtual

This returns the count workunits that depend on this work unit.

Parameters
SchedulerToCountThe 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.

Returns
A Whole is returned containing the count.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual Whole Mezzanine::Threading::iWorkUnit::GetImmediateDependencyCount ( ) const
pure virtual

Get the amount of dependencies that directly count on this for access purposes.

Returns
The amount of accessable WorkUnit from this WorkUnits dependency list.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual Whole Mezzanine::Threading::iWorkUnit::GetPerformance ( ) const
pure virtual

Get the internal rolling average for querying.

Returns
A whole that represents this WorkUnits Performance.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual RunningState Mezzanine::Threading::iWorkUnit::GetRunningState ( ) const
pure virtual

Retrieves the current RunningState of the thread.

Returns
A RunningState that indicates if the thread is running, started, etc... This information can be changed at any time and should be considered stale immediately after retrieval.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual WorkUnitKey Mezzanine::Threading::iWorkUnit::GetSortingKey ( FrameScheduler SchedulerToCount)
pure virtual

Get the sorting metadata.

Parameters
SchedulerToCountThis uses the metadata on the FrameScheduler to generate the Dependency listing required.
Returns
A WorkUnitKey suitable for sorting this workunit.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual bool Mezzanine::Threading::iWorkUnit::IsEveryDependencyComplete ( )
pure virtual

Check if this WorkUnit could concievably run right now.

Returns
This returns true if all of this WorkUnits dependencies have completed execution and false otherwise.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual void Mezzanine::Threading::iWorkUnit::operator() ( DefaultThreadSpecificStorage::Type CurrentThreadStorage)
pure virtual

This tracks work unit metadata, then calls DoWork.

Parameters
CurrentThreadStorageThe ThreadSpecificStorage that this WorkUnit will operate with when executing.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual void Mezzanine::Threading::iWorkUnit::RemoveDependency ( iWorkUnit RemoveDependency)
pure virtual

Remove a dependency.

Parameters
RemoveDependencyA pointer to the WorkUnit to remove as a dependency.

Implemented in Mezzanine::Threading::DefaultWorkUnit.

virtual RunningState Mezzanine::Threading::iWorkUnit::TakeOwnerShip ( )
pure virtual

Attempts to atomically start the work unit in the current thread.

Returns
Returns RunningState::Starting if this thread was able to gain ownership and start the workunit, returns RunningState::NotStarted otherwise.

Implemented in Mezzanine::Threading::DefaultWorkUnit.


The documentation for this class was generated from the following file: