Update of /cvsroot/boost/boost/boost/thread/win32
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7195

Modified Files:
      Tag: thread_rewrite
        basic_timed_mutex.hpp 
Log Message:
New look read-write mutex


Index: basic_timed_mutex.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/thread/win32/Attic/basic_timed_mutex.hpp,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -d -r1.1.2.5 -r1.1.2.6
--- basic_timed_mutex.hpp       5 Oct 2006 07:34:28 -0000       1.1.2.5
+++ basic_timed_mutex.hpp       5 Oct 2006 09:38:21 -0000       1.1.2.6
@@ -9,6 +9,7 @@
 //  accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt)
 
+#include <boost/assert.hpp>
 #include <boost/detail/interlocked.hpp>
 #include <boost/thread/win32/thread_primitives.hpp>
 #include <boost/thread/win32/interlocked_read.hpp>
@@ -58,40 +59,8 @@
             
             void lock()
             {
-                long old_count=0;
-                while(true)
-                {
-                    long const 
current_count=BOOST_INTERLOCKED_COMPARE_EXCHANGE(&active_count,(old_count+1)|lock_flag_value,old_count);
-                    if(current_count==old_count)
-                    {
-                        break;
-                    }
-                    old_count=current_count;
-                }
-
-                if(old_count&lock_flag_value)
-                {
-                    bool lock_acquired=false;
-                    void* const sem=get_semaphore();
-                    ++old_count; // we're waiting, too
-                    do
-                    {
-                        old_count-=(lock_flag_value+1); // there will be one 
less active thread on this mutex when it gets unlocked
-                        BOOST_WAIT_FOR_SINGLE_OBJECT(sem,BOOST_INFINITE);
-                        do
-                        {
-                            long const 
current_count=BOOST_INTERLOCKED_COMPARE_EXCHANGE(&active_count,old_count|lock_flag_value,old_count);
-                            if(current_count==old_count)
-                            {
-                                break;
-                            }
-                            old_count=current_count;
-                        }
-                        while(!(old_count&lock_flag_value));
-                        lock_acquired=!(old_count&lock_flag_value);
-                    }
-                    while(!lock_acquired);
-                }
+                bool const 
success=timed_lock(::boost::detail::get_xtime_sentinel());
+                BOOST_ASSERT(success);
             }
             bool timed_lock(::boost::xtime const& target_time)
             {


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to