voxelTerrain
 All Classes Functions Variables Typedefs Enumerations Pages
idCreator.hpp
1 #ifndef IDCREATOR_HPP
2 #define IDCREATOR_HPP
3 
4 #include "blub/async/mutex.hpp"
5 #include "blub/async/mutexLocker.hpp"
6 
7 namespace blub
8 {
9 
11 template <typename idType>
12 class idCreator
13 {
14 public:
15 
16  idCreator()
17  : m_idCounter(0)
18  {;}
19 
21  idType createId(void)
22  {
23  return ++m_idCounter;
24  }
25 
27  idType createIdThreadSafe(void)
28  {
29  async::mutexLocker locker(m_mutex); (void)locker;
30  return createId();
31  }
32 
33 private:
34  idType m_idCounter;
35  async::mutex m_mutex;
36 
37 };
38 
39 
40 }
41 
42 #endif // IDCREATOR_HPP
Definition: mutex.hpp:13
Definition: idCreator.hpp:12
Definition: mutexLocker.hpp:13
idType createId(void)
Definition: idCreator.hpp:21
Definition: deadlineTimer.hpp:10
idType createIdThreadSafe(void)
Definition: idCreator.hpp:27