Qore Programming Language  0.8.7
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreCondition.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreCondition.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2005 - 2013 David Nichols
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 #ifndef _QORE_QORECONDITION_H
25 
26 #define _QORE_QORECONDITION_H
27 
28 #include <pthread.h>
29 #include <sys/time.h>
30 
31 #include <qore/QoreThreadLock.h>
32 
34 
38 private:
40  pthread_cond_t c;
41 
43  DLLLOCAL QoreCondition(const QoreCondition&);
44 
46  DLLLOCAL QoreCondition& operator=(const QoreCondition&);
47 
48 public:
50  DLLEXPORT QoreCondition();
51 
53  DLLEXPORT ~QoreCondition();
54 
56  DLLEXPORT int signal();
57 
59  DLLEXPORT int broadcast();
60 
62 
66  DLLEXPORT int wait(pthread_mutex_t *m);
67 
69 
74  DLLEXPORT int wait(pthread_mutex_t *m, int timeout_ms);
75 
77 
81  DLLLOCAL int wait(QoreThreadLock *l) {
82  return wait(&l->ptm_lock);
83  }
84 
86 
91  DLLLOCAL int wait(QoreThreadLock *l, int timeout_ms) {
92  return wait(&l->ptm_lock, timeout_ms);
93  }
94 
96 
100  DLLLOCAL int wait(QoreThreadLock &l) {
101  return wait(&l);
102  }
103 
105 
110  DLLLOCAL int wait(QoreThreadLock &l, int timeout_ms) {
111  return wait(&l, timeout_ms);
112  }
113 };
114 
115 #endif // QORE_CONDITION