TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ThreadSet.h
Go to the documentation of this file.
1 #ifndef G3D_ThreadSet_h
2 #define G3D_ThreadSet_h
3 
4 #include "G3D/platform.h"
5 #include "G3D/Array.h"
6 #include "G3D/ReferenceCount.h"
7 #include "G3D/GMutex.h"
8 #include "G3D/SpawnBehavior.h"
9 
10 namespace G3D {
11 
12 class GThread;
13 
19 public:
21  typedef GThread Thread;
22 
23  typedef shared_ptr<Thread> ThreadRef;
24  typedef shared_ptr<ThreadSet> Ref;
27 
28 private:
29 
32 
35 
36 public:
37 
39  int size() const;
40 
42  int numStarted() const;
43 
53  void start(SpawnBehavior lastThreadBehavior = USE_NEW_THREAD) const;
54 
56  void terminate() const;
57 
59  void waitForCompletion() const;
60 
62  void clear();
63 
65  int removeCompleted();
66 
69  int insert(const ThreadRef& t);
70 
73  bool remove(const ThreadRef& t);
74 
75  bool contains(const ThreadRef& t) const;
76 
78  Iterator begin();
79 
80  Iterator end();
81 
82  ConstIterator begin() const;
83 
84  ConstIterator end() const;
85 };
86 
87 
88 } // namespace G3D
89 
90 #endif
Array< ThreadRef > m_thread
Definition: ThreadSet.h:34
shared_ptr< ThreadSet > Ref
Definition: ThreadSet.h:24
int numStarted() const
Definition: ThreadSet.cpp:15
GMutex m_lock
Definition: ThreadSet.h:31
Mutual exclusion lock used for synchronization.
Definition: GMutex.h:76
SpawnBehavior
Definition: SpawnBehavior.h:4
Definition: AABox.h:25
Dynamic 1D array tuned for performance.
Definition: Array.h:95
Iterator begin()
Definition: ThreadSet.cpp:150
shared_ptr< Thread > ThreadRef
Definition: ThreadSet.h:23
void start(SpawnBehavior lastThreadBehavior=USE_NEW_THREAD) const
Definition: ThreadSet.cpp:29
bool contains(const ThreadRef &t) const
Definition: ThreadSet.cpp:138
void waitForCompletion() const
Definition: ThreadSet.cpp:74
Definition: ReferenceCount.h:24
int insert(const ThreadRef &t)
Definition: ThreadSet.cpp:109
Array< ThreadRef >::Iterator Iterator
Definition: ThreadSet.h:25
void clear()
Definition: ThreadSet.cpp:102
Array< ThreadRef >::ConstIterator ConstIterator
Definition: ThreadSet.h:26
Definition: SpawnBehavior.h:4
int size() const
Definition: ThreadSet.cpp:6
Definition: ThreadSet.h:18
Definition: GThread.h:42
Iterator end()
Definition: ThreadSet.cpp:155
int removeCompleted()
Definition: ThreadSet.cpp:87
void terminate() const
Definition: ThreadSet.cpp:62
GThread Thread
Definition: ThreadSet.h:21