|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62505 - trunk/boost/thread/win32
From: anthony_at_[hidden]
Date: 2010-06-07 05:08:09
Author: anthonyw
Date: 2010-06-07 05:08:09 EDT (Mon, 07 Jun 2010)
New Revision: 62505
URL: http://svn.boost.org/trac/boost/changeset/62505
Log:
Applied patch from ticket 2918
Text files modified:
trunk/boost/thread/win32/shared_mutex.hpp | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
Modified: trunk/boost/thread/win32/shared_mutex.hpp
==============================================================================
--- trunk/boost/thread/win32/shared_mutex.hpp (original)
+++ trunk/boost/thread/win32/shared_mutex.hpp 2010-06-07 05:08:09 EDT (Mon, 07 Jun 2010)
@@ -49,33 +49,35 @@
return *reinterpret_cast<T const*>(&res);
}
+ enum
+ {
+ unlock_sem = 0,
+ exclusive_sem = 1
+ };
+
state_data state;
detail::win32::handle semaphores[2];
- detail::win32::handle &unlock_sem;
- detail::win32::handle &exclusive_sem;
detail::win32::handle upgrade_sem;
void release_waiters(state_data old_state)
{
if(old_state.exclusive_waiting)
{
- BOOST_VERIFY(detail::win32::ReleaseSemaphore(exclusive_sem,1,0)!=0);
+ BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[exclusive_sem],1,0)!=0);
}
if(old_state.shared_waiting || old_state.exclusive_waiting)
{
- BOOST_VERIFY(detail::win32::ReleaseSemaphore(unlock_sem,old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0);
+ BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0);
}
}
public:
- shared_mutex():
- unlock_sem(semaphores[0]),
- exclusive_sem(semaphores[1])
+ shared_mutex()
{
- unlock_sem=detail::win32::create_anonymous_semaphore(0,LONG_MAX);
- exclusive_sem=detail::win32::create_anonymous_semaphore(0,LONG_MAX);
+ semaphores[unlock_sem]=detail::win32::create_anonymous_semaphore(0,LONG_MAX);
+ semaphores[exclusive_sem]=detail::win32::create_anonymous_semaphore(0,LONG_MAX);
upgrade_sem=detail::win32::create_anonymous_semaphore(0,LONG_MAX);
state_data state_={0};
state=state_;
@@ -84,8 +86,8 @@
~shared_mutex()
{
detail::win32::CloseHandle(upgrade_sem);
- detail::win32::CloseHandle(unlock_sem);
- detail::win32::CloseHandle(exclusive_sem);
+ detail::win32::CloseHandle(semaphores[unlock_sem]);
+ detail::win32::CloseHandle(semaphores[exclusive_sem]);
}
bool try_lock_shared()
@@ -150,7 +152,7 @@
return true;
}
- unsigned long const res=detail::win32::WaitForSingleObject(unlock_sem,::boost::detail::get_milliseconds_until(wait_until));
+ unsigned long const res=detail::win32::WaitForSingleObject(semaphores[unlock_sem],::boost::detail::get_milliseconds_until(wait_until));
if(res==detail::win32::timeout)
{
for(;;)
@@ -394,7 +396,7 @@
return;
}
- BOOST_VERIFY(!detail::win32::WaitForSingleObject(unlock_sem,detail::win32::infinite));
+ BOOST_VERIFY(!detail::win32::WaitForSingleObject(semaphores[unlock_sem],detail::win32::infinite));
}
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk