Spinning Topp Logo BlackTopp Studios
inc
workunitkey.cpp
Go to the documentation of this file.
1 // The DAGFrameScheduler is a Multi-Threaded lock free and wait free scheduling library.
2 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
3 /* This file is part of The DAGFrameScheduler.
4 
5  The DAGFrameScheduler is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  The DAGFrameScheduler is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with The DAGFrameScheduler. If not, see <http://www.gnu.org/licenses/>.
17 */
18 /* The original authors have included a copy of the license specified above in the
19  'doc' folder. See 'gpl.txt'
20 */
21 /* We welcome the use of the DAGFrameScheduler to anyone, including companies who wish to
22  Build professional software and charge for their product.
23 
24  However there are some practical restrictions, so if your project involves
25  any of the following you should contact us and we will try to work something
26  out:
27  - DRM or Copy Protection of any kind(except Copyrights)
28  - Software Patents You Do Not Wish to Freely License
29  - Any Kind of Linking to Non-GPL licensed Works
30  - Are Currently In Violation of Another Copyright Holder's GPL License
31  - If You want to change our code and not add a few hundred MB of stuff to
32  your distribution
33 
34  These and other limitations could cause serious legal problems if you ignore
35  them, so it is best to simply contact us or the Free Software Foundation, if
36  you have any questions.
37 
38  Joseph Toppi - toppij@gmail.com
39  John Blackwood - makoenergy02@gmail.com
40 */
41 #ifndef _timeddagworkunitkey_cpp
42 #define _timeddagworkunitkey_cpp
43 
44 #include "workunitkey.h"
45 
46 
47 /// @file
48 /// @brief This file declares the functionality of the metadata used to sort the @ref Mezzanine::Threading::iWorkUnit "iWorkUnit"s.
49 
50 namespace Mezzanine
51 {
52  namespace Threading
53  {
55  : Unit(0), Dependers(0), Time(0)
56  {}
57 
58  WorkUnitKey::WorkUnitKey(const Whole& Dependers_, const Whole& Time_, iWorkUnit* WorkUnit_)
59  : Unit(WorkUnit_), Dependers(Dependers_), Time(Time_)
60  {}
61 
63  {}
64 
65  bool WorkUnitKey::operator< (const WorkUnitKey& rhs ) const
66  {
67  if (this->Dependers < rhs.Dependers) // reduce priority of Items with fewer dependents
68  { return true; }
69  if (this->Dependers == rhs.Dependers)
70  {
71  if (this->Time < rhs.Time) // reduce priority of faster workunits
72  { return true; }
73  if (this->Time == rhs.Time)
74  { return this->Unit < rhs.Unit; }
75  }
76  return false;
77  }
78 
79  bool WorkUnitKey::operator ==(const WorkUnitKey &rhs) const
80  { return Unit == rhs.Unit; }
81  }//Threading
82 }//Mezzanine
83 #endif
Whole Time
Some representation of the time the target workunit takes to execute.
Definition: workunitkey.h:80
Whole Dependers
This stores how many things must run after the target workunit.
Definition: workunitkey.h:71
Stores data about a single work unit so that it can easily be sorted.
Definition: workunitkey.h:56
Interface of a WorkUnit. This represents on piece of work through time.
Definition: workunit.h:66
virtual bool operator<(const WorkUnitKey &rhs) const
The function that does the comparison in most containers.
Definition: workunitkey.cpp:65
virtual ~WorkUnitKey()
Destructor.
Definition: workunitkey.cpp:62
iWorkUnit * Unit
The WorkUnit this carries metadata for.
Definition: workunitkey.h:60
This file defines the metadata used to sort workunits.
WorkUnitKey()
Default Constructor.
Definition: workunitkey.cpp:54
A container for the metrics of time relevant for the timer class.
Definition: extendedtimer.h:52
virtual bool operator==(const WorkUnitKey &rhs) const
Does this key point to the Same work unit as another?
Definition: workunitkey.cpp:79
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151