wefts_cond.h

Go to the documentation of this file.
00001 /* 00002 wefts_cond.h 00003 Abstract class implementing a condition variable. 00004 00005 $Id: wefts_cond.h,v 1.14 2004/03/28 21:45:40 jonnymind Exp $ 00006 ---------------------------------------------- 00007 Begin : 2003-08-02 00:10 00008 Author : Giancarlo Niccolai 00009 00010 Last modified because: 00011 Implementing OS independent base threading 00012 */ 00013 00014 /************************************************************************** 00015 * This program is free software; you can redistribute it and/or modify * 00016 * it under the terms of the GNU Library General Public License as * 00017 * published by the Free Software Foundation; either version 2.1 of the * 00018 * License, or (at your option) any later version. * 00019 ***************************************************************************/ 00020 00021 #ifndef WT_COND_H 00022 #define WT_COND_H 00023 00024 #include <wefts_mutex.h> 00025 #include <wefts_cleancond.h> 00026 00027 namespace Wefts { 00028 00045 class Condition 00046 { 00047 protected: 00049 OSCondition m_cond; 00054 Mutex *m_my_mutex; 00055 00056 00057 public: 00060 Condition( Mutex *mtx=0 ) 00061 { 00062 m_my_mutex = mtx; 00063 } 00064 00065 ~Condition() {} 00066 00076 virtual inline bool wait( CleanupHandler *cup = 0, int pos = 0 ) { 00077 CleanupItem clup( cup, pos, this ); 00078 return m_cond.wait( m_my_mutex->m_mutex, clup ); 00079 } 00080 00088 void setMutex( Mutex *mtx) { m_my_mutex = mtx; } 00089 /* Returns the mutex used by this condition. */ 00090 Mutex *getMutex() { return m_my_mutex; } 00091 00113 virtual inline bool wait( long seconds, long nanoseconds, CleanupHandler *cup = 0, int pos = 0) 00114 { 00115 CleanupItem clup( cup, pos, this ); 00116 return m_cond.timedWait( m_my_mutex->m_mutex, seconds, nanoseconds, clup ); 00117 } 00118 00119 00134 inline bool wait( double seconds, CleanupHandler *cup = 0, int pos = 0 ) 00135 { 00136 return wait( long( seconds ), 00137 long( (seconds - long(seconds)) *1000000000l), cup, pos ); 00138 } 00139 00143 virtual inline void signal() { m_cond.signal(); } 00144 00155 virtual inline void signalOne() { m_cond.signalOne(); } 00156 00157 }; 00158 00159 } 00160 00161 #endif 00162 /* end of wefts_cond.h */

Generated on Tue Oct 5 14:57:00 2004 for Wefts by doxygen 1.3.7