xoreos  0.0.5
animationthread.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_AURORA_ANIMATIONTHREAD_H
26 #define GRAPHICS_AURORA_ANIMATIONTHREAD_H
27 
28 #include <queue>
29 
30 #include <boost/atomic.hpp>
31 
32 #include "glm/vec3.hpp"
33 #include "glm/vec4.hpp"
34 
35 #include "src/common/mutex.h"
36 #include "src/common/thread.h"
37 
38 namespace Graphics {
39 
40 namespace Aurora {
41 
42 class Model;
43 
45 public:
47  void pause();
48  void resume();
49 
50  // .--- Processing pool
52  void registerModel(Model *model);
54  void unregisterModel(Model *model);
56  void flush();
57  // '---
58 private:
59  struct PoolModel {
63 
64  PoolModel(Model *m);
65  };
66 
67  typedef std::list<PoolModel> ModelList;
68  typedef std::queue<Model *> ModelQueue;
69 
72 
73  boost::atomic<bool> _paused;
74  boost::atomic<bool> _flushing;
75 
78 
79  void threadMethod();
80  void registerModelInternal(Model *model);
81  void unregisterModelInternal(Model *model);
82  uint8 getNumIterationsToSkip(Model *model) const;
83 };
84 
85 } // End of namespace Aurora
86 
87 } // End of namespace Engines
88 
89 #endif // GRAPHICS_AURORA_ANIMATIONTHREAD_H
uint8_t uint8
Definition: types.h:200
A semaphore .
Definition: mutex.h:55
void unregisterModelInternal(Model *model)
boost::atomic< bool > _flushing
std::queue< Model * > ModelQueue
void unregisterModel(Model *model)
Remove a model from the processing pool.
Threading helpers.
A class that creates its own thread.
Definition: thread.h:44
void registerModel(Model *model)
Add a model to the processing pool.
std::list< PoolModel > ModelList
void flush()
Apply changes to position and geometry of all models in the processing pool.
Thread mutex classes.
uint8 getNumIterationsToSkip(Model *model) const
uint32_t uint32
Definition: types.h:204
uint8 skippedCount
Number of skipped loop iterations.
Common::Semaphore _modelsSem
Semaphore protecting access to the model list.
Common::Semaphore _registerSem
Semaphore protecting access to the registration queue.