00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __UT_ThreadSharedLock_h__
00019 #define __UT_ThreadSharedLock_h__
00020
00021 #include "UT_API.h"
00022 #include "UT_Thread.h"
00023 #include "UT_Lock.h"
00024 #include "UT_Condition.h"
00025
00026 #if defined(USE_BOOST_CONDITIONS)
00027 #include <boost/thread/mutex.hpp>
00028 #include <boost/thread/condition_variable.hpp>
00029 #include <boost/thread/locks.hpp>
00030 #endif
00031
00032 class UT_API UT_ThreadSharedLock
00033 {
00034 public:
00035 UT_ThreadSharedLock();
00036 ~UT_ThreadSharedLock();
00037
00038
00039
00040
00041
00042 static void setGroupIdForThisThread(ut_thread_id_t group_id);
00043
00044 void lock();
00045 void unlock();
00046
00047 private:
00048
00049
00050 UT_ThreadSharedLock(const UT_ThreadSharedLock &);
00051 UT_ThreadSharedLock &operator=(const UT_ThreadSharedLock &);
00052
00053 #if !defined(USE_BOOST_CONDITIONS)
00054 UT_Lock myCriticalSectionLock;
00055 UT_Condition myCondition;
00056 #else
00057 boost::mutex myCriticalSectionLock;
00058 boost::condition_variable myCondition;
00059 #endif
00060 int myLockCount;
00061 ut_thread_id_t myThreadGroupIdWithLock;
00062 int myNumWaitingThreads;
00063 };
00064
00065 #endif