MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
monopoly.h
Go to the documentation of this file.
1 // The DAGFrameScheduler is a Multi-Threaded lock free and wait free scheduling library.
2 // © Copyright 2010 - 2014 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 _threadmonopoly_h
42 #define _threadmonopoly_h
43 
44 #include "datatypes.h"
45 
46 #if !defined(SWIG) || defined(SWIG_THREADING) // Do not read when in swig and not in the threading module
47 #include "doublebufferedresource.h"
48 #include "workunit.h"
49 #endif
50 
51 /// @file
52 /// @brief Contains an interface for a kind of WorkUnit that consumes time on multiple thread
53 
54 namespace Mezzanine
55 {
56  namespace Threading
57  {
58  class FrameScheduler;
59 
60  /// @brief A kind of workunit given exclusive runtime so it can consume time on multiple threads
61  /// @details A @ref FrameScheduler executes monopolies before other and will allow them to run with on every thread.
63  {
64  public:
65  /// @brief Provides a hint to the monopoly as to how many threads it should use.
66  /// @param AmountToUse The amount of threads you would like the monopoly to consume.
67  virtual void UseThreads(const Whole& AmountToUse) = 0;
68 
69  /// @brief Retrieves the amount of threads that the monopoly will actually use.
70  /// @details The monopoly is free to ignore any value passed @ref UseThreads and
71  /// use any heuristic or threading model instead.
72  /// @return A whole with the amount of threads to be used.
73  virtual Whole UsingThreadCount() = 0;
74 
75  /// @brief A virtual destructor, currently empty.
76  virtual ~MonopolyWorkUnit();
77  };//MonopolyWorkUnit
78  }//Threading
79 }//Mezzanine
80 #endif