Qore Programming Language: include/qore/QoreCondition.h (6585) Source File

Qore Programming Language 0.8.11

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

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 - 2014 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
37 class QoreCondition {
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
76 DLLEXPORT int wait(pthread_mutex_t *m, int timeout_ms);
77
79
84 DLLEXPORT int wait2(pthread_mutex_t *m, int64 timeout_ms);
85
87
91 DLLLOCAL int wait(QoreThreadLock *l) {
92 return wait(&l->ptm_lock);
93 }
94
96
103 DLLLOCAL int wait(QoreThreadLock *l, int timeout_ms) {
104 return wait(&l->ptm_lock, timeout_ms);
105 }
106
108
113 DLLLOCAL int wait2(QoreThreadLock *l, int64 timeout_ms) {
114 return wait2(&l->ptm_lock, timeout_ms);
115 }
116
118
122 DLLLOCAL int wait(QoreThreadLock &l) {
123 return wait(&l);
124 }
125
127
134 DLLLOCAL int wait(QoreThreadLock &l, int timeout_ms) {
135 return wait(&l, timeout_ms);
136 }
137
139
144 DLLLOCAL int wait2(QoreThreadLock &l, int64 timeout_ms) {
145 return wait2(&l, timeout_ms);
146 }
147 };
148
149 #endif // QORE_CONDITION
QoreCondition::wait
DLLLOCAL int wait(QoreThreadLock &l, int timeout_ms)
blocks a thread on a lock for a certain number of milliseconds until the condition is signaled ...
Definition: QoreCondition.h:134
QoreCondition::wait2
DLLLOCAL int wait2(QoreThreadLock *l, int64 timeout_ms)
blocks a thread on a lock for a certain number of milliseconds until the condition is signaled ...
Definition: QoreCondition.h:113
QoreCondition::wait2
DLLLOCAL int wait2(QoreThreadLock &l, int64 timeout_ms)
blocks a thread on a lock for a certain number of milliseconds until the condition is signaled ...
Definition: QoreCondition.h:144
QoreCondition::wait
DLLLOCAL int wait(QoreThreadLock &l)
blocks a thread on a lock until the condition is signaled
Definition: QoreCondition.h:122
QoreCondition::wait
DLLLOCAL int wait(QoreThreadLock *l)
blocks a thread on a lock until the condition is signaled
Definition: QoreCondition.h:91
QoreCondition::signal
DLLEXPORT int signal()
signals a single waiting thread to wake up
QoreCondition
a thread condition class implementing a wrapper for pthread_cond_t
Definition: QoreCondition.h:37
QoreCondition::broadcast
DLLEXPORT int broadcast()
singles all threads blocked on this condition to wake up
QoreCondition::~QoreCondition
DLLEXPORT ~QoreCondition()
destroys the condition object
QoreCondition::wait
DLLLOCAL int wait(QoreThreadLock *l, int timeout_ms)
blocks a thread on a lock for a certain number of milliseconds until the condition is signaled ...
Definition: QoreCondition.h:103
QoreThreadLock
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:41
QoreCondition::QoreCondition
DLLEXPORT QoreCondition()
creates the condition object
QoreCondition::wait2
DLLEXPORT int wait2(pthread_mutex_t *m, int64 timeout_ms)
blocks a thread on a mutex for a certain number of milliseconds until the condition is signaled ...
QoreCondition::wait
DLLEXPORT int wait(pthread_mutex_t *m)
blocks a thread on a mutex until the condition is signaled