00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 //---------------------------------------------------------------------- 00012 //---------------------------------------------------------------------- 00013 #ifndef ICL_CORE_THREAD_RWLOCK_IMPL_WIN32_H_INCLUDED 00014 #define ICL_CORE_THREAD_RWLOCK_IMPL_WIN32_H_INCLUDED 00015 00016 #include <vector> 00017 #include <Windows.h> 00018 00019 #include "icl_core_thread/RWLockImpl.h" 00020 #include "icl_core_thread/Mutex.h" 00021 00022 namespace icl_core { 00023 namespace thread { 00024 00025 class RWLockImplWin32 : public RWLockImpl, protected virtual icl_core::Noncopyable 00026 { 00027 public: 00028 RWLockImplWin32(); 00029 virtual ~RWLockImplWin32(); 00030 00031 virtual bool readLock(); 00032 virtual bool readLock(const TimeStamp& timeout); 00033 virtual bool readLock(const TimeSpan& timeout); 00034 virtual bool tryReadLock(); 00035 00036 virtual bool writeLock(); 00037 virtual bool writeLock(const TimeStamp& timeout); 00038 virtual bool writeLock(const TimeSpan& timeout); 00039 virtual bool tryWriteLock(); 00040 00041 virtual void unlock(); 00042 00043 private: 00044 bool readLock(DWORD timeout); 00045 bool writeLock(DWORD timeout); 00046 00047 Mutex m_reader_access_lock; 00048 HANDLE m_reader_mutex_event; 00049 HANDLE m_writer_mutex; 00050 int m_number_of_writer; 00051 int m_number_of_reader; 00052 int m_writer_pid; 00053 std::vector<int> m_reader_pid; 00054 }; 00055 00056 } 00057 } 00058 00059 #endif