|
Qore Programming Language
0.8.3
|
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */ 00002 /* 00003 QoreCondition.h 00004 00005 Qore Programming Language 00006 00007 Copyright (C) David Nichols 2005 - 2011 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #ifndef _QORE_QORECONDITION_H 00025 00026 #define _QORE_QORECONDITION_H 00027 00028 #include <pthread.h> 00029 #include <sys/time.h> 00030 00031 #include <qore/QoreThreadLock.h> 00032 00034 00037 class QoreCondition { 00038 private: 00040 pthread_cond_t c; 00041 00043 DLLLOCAL QoreCondition(const QoreCondition&); 00044 00046 DLLLOCAL QoreCondition& operator=(const QoreCondition&); 00047 00048 public: 00050 DLLEXPORT QoreCondition(); 00051 00053 DLLEXPORT ~QoreCondition(); 00054 00056 DLLEXPORT int signal(); 00057 00059 DLLEXPORT int broadcast(); 00060 00062 00066 DLLEXPORT int wait(pthread_mutex_t *m); 00067 00069 00074 DLLEXPORT int wait(pthread_mutex_t *m, int timeout_ms); 00075 00077 00081 DLLLOCAL int wait(QoreThreadLock *l) { 00082 return wait(&l->ptm_lock); 00083 } 00084 00086 00091 DLLLOCAL int wait(QoreThreadLock *l, int timeout_ms) { 00092 return wait(&l->ptm_lock, timeout_ms); 00093 } 00094 00096 00100 DLLLOCAL int wait(QoreThreadLock &l) { 00101 return wait(&l); 00102 } 00103 00105 00110 DLLLOCAL int wait(QoreThreadLock &l, int timeout_ms) { 00111 return wait(&l, timeout_ms); 00112 } 00113 }; 00114 00115 #endif // QORE_CONDITION