tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
threadbarrier.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 //
4 //
5 //------------------------------------------------------------------------------
6 
7 #ifndef _BARRIER_INCLUDED_
8 #define _BARRIER_INCLUDED_
9 
10 #include <atomic>
11 #include <iostream>
12 
14 {
15 public:
16  ThreadBarrier(unsigned numThread)
17  : m_numThread(numThread)
18  , m_arrived(0)
19  {}
20 
21  void Wait()
22  {
23  m_arrived++;
24 
25  while(m_arrived < m_numThread);
26  }
27 
28 private:
29  unsigned m_numThread;
30  std::atomic<unsigned> m_arrived;
31 };
32 
33 #endif //_BARRIER_INCLUDED_
Definition: threadbarrier.h:13
ThreadBarrier(unsigned numThread)
Definition: threadbarrier.h:16
void Wait()
Definition: threadbarrier.h:21
std::atomic< unsigned > m_arrived
Definition: threadbarrier.h:30
unsigned m_numThread
Definition: threadbarrier.h:29