Spinning Topp Logo BlackTopp Studios
inc
doublebufferedresource.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 _doublebufferedresource_cpp
42 #define _doublebufferedresource_cpp
43 
44 #include "datatypes.h"
45 #include "doublebufferedresource.h"
46 #include "framescheduler.h"
47 
48 /// @file
49 /// @brief This file defines the template double buffered resources that can be attached to a thread.
50 
51 namespace Mezzanine
52 {
53  namespace Threading
54  {
56  Scheduler(Scheduler_)
57  {
58  this->ThreadResources.push_back((ConvertiblePointer)new DoubleBufferedLogger); // must comes first so it lands in spot 0
59  }
60 
62  { return GetResource<DoubleBufferedLogger>(DBRLogger).GetUsable(); }
63 
65  { return Scheduler; }
66 
68  { return Scheduler->GetLastFrameTime() ; }
69 
71  { return Scheduler->GetLastPauseTime(); }
72 
74  { return Scheduler->GetCurrentFrameStart(); }
75 
77  { GetResource<DoubleBufferedLogger>(DBRLogger).SwapUsableAndCommitable(); }
78 
80  {
81  delete (DoubleBufferedLogger*)this->ThreadResources[DBRLogger]; // Items must wind up in the correct spot in the vector for this to work. Be careful to get the order right if you overload this.
82  }
83 
84  }//Threading
85 }//Mezzanine
86 
87 #endif
std::stringstream Logger
In case we ever replace the stringstream with another class, this will allow us to swap it out...
Definition: datatypes.h:180
FrameScheduler * GetFrameScheduler()
Get a pointer to the FrameScheduler that owns this resource.
Whole GetLastPauseTime() const
How long was the pause, if any, last frame?
All the definitions for datatypes as well as some basic conversion functions are defined here...
Whole GetLastFrameTime() const
How long was the previous frame?
This file defines the template double buffered resources that can be attached to a thread...
static const Whole DBRLogger
Double buffered resources are identified by a Whole which is their type ID, This number identifies lo...
This file has the Declarations for the main FrameScheduler class.
virtual MaxInt GetCurrentFrameStart() const
When did this frame start?
virtual ~ThreadSpecificStorage()
Deletes all the resources.
This is central object in this algorithm, it is responsible for spawning threads and managing the ord...
ThreadSpecificStorage(FrameScheduler *Scheduler_)
A constructor that automatically creates the resources it supports.
Logger & GetUsableLogger()
Get the usable logger for this thread specific resource.
MaxInt GetCurrentFrameStart() const
When did this frame start?
A thread specific resource that uses double buffering to avoid multithreaded synchronization mechanis...
long long MaxInt
A large integer type suitable for compile time math and long term microsecond time keeping...
Definition: datatypes.h:190
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
intptr_t ConvertiblePointer
A type that any pointer can be converted to and back from, and insures after the conversion back it w...
Definition: datatypes.h:112
void SwapAllBufferedResources()
The commitable and usable version of every double buffered resource for this thread specific storage ...
Whole GetLastPauseTime() const
How long was the pause, if any, last frame?
Whole GetLastFrameTime() const
How long was the previous frame?