cheshirekow  v0.1.0
condition.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_CONDITION_H_
28 #define CPP_PTHREADS_CONDITION_H_
29 
30 #include <pthread.h>
31 
32 #include <cpp_pthreads/attr.h>
33 #include <cpp_pthreads/mutex.h>
34 
35 namespace pthreads {
36 
38 
44 class Condition {
45  private:
46  pthread_cond_t m_data;
47 
48  public:
50  int init();
51 
53  int init(const Attr<Condition>& attr);
54 
56  int destroy();
57 
59  int broadcast();
60 
62  int signal();
63 
65  int wait(Mutex& mutex);
66 
67 };
68 
69 } // namespace pthreads
70 
71 #endif // CONDITION_H_
pthread_cond_t m_data
Definition: condition.h:46
int broadcast()
signals all threads waiting on the condition
int init()
calls initializes a condition variable with default attributes
Attributes object for type Base.
Definition: attr.h:35
int destroy()
destroys a condition variable
a mutual exclusion lock
Definition: mutex.h:85
int wait(Mutex &mutex)
called by a thread that wishes to wait on this condition
Allows multiple threads to wait until a condition is satisfied.
Definition: condition.h:44
int signal()
signals one thread waiting on the condition