cheshirekow  v0.1.0
barrier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of cpp-pthreads.
5  *
6  * cpp-pthreads is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * cpp-pthreads is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with cpp-pthreads. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef CPP_PTHREADS_BARRIER_H_
28 #define CPP_PTHREADS_BARRIER_H_
29 
30 #include <pthread.h>
31 #include <cpp_pthreads/attr.h>
32 
33 namespace pthreads {
34 
37 
42 class Barrier {
43  private:
44  pthread_barrier_t m_data;
45 
46  public:
48  int init(unsigned count);
49 
52  int init(const Attr<Barrier>& attr, unsigned count);
53 
55  int destroy();
56 
59  int wait();
60 
61 };
62 
63 } // namespace pthreads
64 
65 #endif // BARRIER_H_
int wait()
called by a thread which wishes to synchronize on the barrier. Will block until count threads are all...
int destroy()
destroy the barrier
pthread_barrier_t m_data
Definition: barrier.h:44
A barrier is an object which synchronizes a fixed number of threads at a specific point...
Definition: barrier.h:42
Attributes object for type Base.
Definition: attr.h:35
int init(unsigned count)
initialize a barrier for count threads using default attributes