Stores data about a single work unit so that it can easily be sorted. More...
#include <workunitkey.h>
Public Member Functions | |
WorkUnitKey () | |
Default Constructor. More... | |
WorkUnitKey (const Whole &Dependers_, const Whole &Time_, iWorkUnit *WorkUnit_) | |
Constructor. More... | |
virtual | ~WorkUnitKey () |
Destructor. | |
virtual bool | operator< (const WorkUnitKey &rhs) const |
The function that does the comparison in most containers. More... | |
virtual bool | operator== (const WorkUnitKey &rhs) const |
Does this key point to the Same work unit as another? More... | |
Public Attributes | |
Whole | Dependers |
This stores how many things must run after the target workunit. More... | |
Whole | Time |
Some representation of the time the target workunit takes to execute. More... | |
iWorkUnit * | Unit |
The WorkUnit this carries metadata for. | |
Stores data about a single work unit so that it can easily be sorted.
Definition at line 56 of file workunitkey.h.
Mezzanine::Threading::WorkUnitKey::WorkUnitKey | ( | ) |
Default Constructor.
This creates an empty and quite useless Key, needs to be filled with data before being useful.
Definition at line 54 of file workunitkey.cpp.
Mezzanine::Threading::WorkUnitKey::WorkUnitKey | ( | const Whole & | Dependers_, |
const Whole & | Time_, | ||
iWorkUnit * | WorkUnit_ | ||
) |
Constructor.
Dependers_ | How many items depend on this. This needs to be calculated the same for all WorkUnitKeys. |
Time_ | How long is this workunit expected to execute for. This needs to be calculated the same for all WorkUnitKeys. |
WorkUnit_ | A pointer to the workunit in question. |
Definition at line 58 of file workunitkey.cpp.
|
virtual |
The function that does the comparison in most containers.
rhs | The right hand WorkUnitKey when using <. |
This enforces the algorithm that sorts workunits. The workunit with the most other work units depending on it is priotized first. Because the longest delays in execution time can be introduced if WorkUnits are waiting for a dependency and it is poorly scheduled, this can results in single threaded execution when more could have been possible. If there is a tie in dependent count, then the work unit that takes longer to execute is prioritized (this needs to be tested for correctness). This starts WorkUnits that take longer earlier in the frame, helping to minimize the length of the critical path. In the event that those are both tied, then the WorkUnit with the lowest pointer value is priotized to prevent any of WorkUnitKey from comparing identically.
Definition at line 65 of file workunitkey.cpp.
|
virtual |
Does this key point to the Same work unit as another?
rhs | The other key. |
Definition at line 79 of file workunitkey.cpp.
Whole Mezzanine::Threading::WorkUnitKey::Dependers |
This stores how many things must run after the target workunit.
This is most important sorting factor. In the Default algorithm. All of the Workunit that the most workunits depend on are run before the any others. Since this number is usually low (less than 10ish) in large groups of workunits, then there must be a tie-breaker. This should be calculated including the dependers of all the dependers (I don't think counting a workunit twice hurts, and it may even help if something actually depend on multiple workunits that depend on this.)
Definition at line 71 of file workunitkey.h.
Whole Mezzanine::Threading::WorkUnitKey::Time |
Some representation of the time the target workunit takes to execute.
In the default algorithm this is used to determine what executes first after dependents are counted. It is important to know what takes the longest time and start it first so that it might finish coterminously with shorter workunits. This is used second because length of execution of one workunit means nothing if many other workunits run serialized in one thread rather than in parrellel.
Definition at line 80 of file workunitkey.h.