1 #ifndef BOOST_THREAD_V2_SHARED_MUTEX_HPP
2 #define BOOST_THREAD_V2_SHARED_MUTEX_HPP
6 // Copyright Howard Hinnant 2007-2010.
7 // Copyright Vicente J. Botet Escriba 2012.
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
14 <shared_mutex> synopsis
28 shared_mutex(const shared_mutex&) = delete;
29 shared_mutex& operator=(const shared_mutex&) = delete;
31 // Exclusive ownership
35 template <class Rep, class Period>
36 bool try_lock_for(const boost::chrono::duration<Rep, Period>& rel_time);
37 template <class Clock, class Duration>
40 const boost::chrono::time_point<Clock, Duration>& abs_time);
46 bool try_lock_shared();
47 template <class Rep, class Period>
49 try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time);
50 template <class Clock, class Duration>
52 try_lock_shared_until(
53 const boost::chrono::time_point<Clock, Duration>& abs_time);
64 upgrade_mutex(const upgrade_mutex&) = delete;
65 upgrade_mutex& operator=(const upgrade_mutex&) = delete;
67 // Exclusive ownership
71 template <class Rep, class Period>
72 bool try_lock_for(const boost::chrono::duration<Rep, Period>& rel_time);
73 template <class Clock, class Duration>
76 const boost::chrono::time_point<Clock, Duration>& abs_time);
82 bool try_lock_shared();
83 template <class Rep, class Period>
85 try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time);
86 template <class Clock, class Duration>
88 try_lock_shared_until(
89 const boost::chrono::time_point<Clock, Duration>& abs_time);
95 bool try_lock_upgrade();
96 template <class Rep, class Period>
99 const boost::chrono::duration<Rep, Period>& rel_time);
100 template <class Clock, class Duration>
102 try_lock_upgrade_until(
103 const boost::chrono::time_point<Clock, Duration>& abs_time);
104 void unlock_upgrade();
106 // Shared <-> Exclusive
108 bool try_unlock_shared_and_lock();
109 template <class Rep, class Period>
111 try_unlock_shared_and_lock_for(
112 const boost::chrono::duration<Rep, Period>& rel_time);
113 template <class Clock, class Duration>
115 try_unlock_shared_and_lock_until(
116 const boost::chrono::time_point<Clock, Duration>& abs_time);
117 void unlock_and_lock_shared();
119 // Shared <-> Upgrade
121 bool try_unlock_shared_and_lock_upgrade();
122 template <class Rep, class Period>
124 try_unlock_shared_and_lock_upgrade_for(
125 const boost::chrono::duration<Rep, Period>& rel_time);
126 template <class Clock, class Duration>
128 try_unlock_shared_and_lock_upgrade_until(
129 const boost::chrono::time_point<Clock, Duration>& abs_time);
130 void unlock_upgrade_and_lock_shared();
132 // Upgrade <-> Exclusive
134 void unlock_upgrade_and_lock();
135 bool try_unlock_upgrade_and_lock();
136 template <class Rep, class Period>
138 try_unlock_upgrade_and_lock_for(
139 const boost::chrono::duration<Rep, Period>& rel_time);
140 template <class Clock, class Duration>
142 try_unlock_upgrade_and_lock_until(
143 const boost::chrono::time_point<Clock, Duration>& abs_time);
144 void unlock_and_lock_upgrade();
152 #include <boost/thread/detail/config.hpp>
153 #include <boost/thread/mutex.hpp>
154 #include <boost/thread/condition_variable.hpp>
155 #include <boost/thread/mutex.hpp>
156 #include <boost/chrono.hpp>
158 #include <boost/system/system_error.hpp>
159 #define BOOST_THREAD_INLINE inline
162 namespace thread_v2 {
166 typedef ::boost::mutex mutex_t;
167 typedef ::boost::condition_variable cond_t;
168 typedef unsigned count_t;
175 static const count_t write_entered_ = 1U << (sizeof(count_t)*CHAR_BIT - 1);
176 static const count_t n_readers_ = ~write_entered_;
179 BOOST_THREAD_INLINE shared_mutex();
180 BOOST_THREAD_INLINE ~shared_mutex();
182 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
183 shared_mutex(shared_mutex const&) = delete;
184 shared_mutex& operator=(shared_mutex const&) = delete;
185 #else // BOOST_NO_CXX11_DELETED_FUNCTIONS
187 shared_mutex(shared_mutex const&);
188 shared_mutex& operator=(shared_mutex const&);
190 #endif // BOOST_NO_CXX11_DELETED_FUNCTIONS
192 // Exclusive ownership
194 BOOST_THREAD_INLINE void lock();
195 BOOST_THREAD_INLINE bool try_lock();
196 template <class Rep, class Period>
197 bool try_lock_for(const boost::chrono::duration<Rep, Period>& rel_time)
199 return try_lock_until(boost::chrono::steady_clock::now() + rel_time);
201 template <class Clock, class Duration>
204 const boost::chrono::time_point<Clock, Duration>& abs_time);
205 BOOST_THREAD_INLINE void unlock();
210 BOOST_THREAD_INLINE void lock_shared();
211 BOOST_THREAD_INLINE bool try_lock_shared();
212 template <class Rep, class Period>
214 try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
216 return try_lock_shared_until(boost::chrono::steady_clock::now() +
219 template <class Clock, class Duration>
221 try_lock_shared_until(
222 const boost::chrono::time_point<Clock, Duration>& abs_time);
223 BOOST_THREAD_INLINE void unlock_shared();
225 #if defined BOOST_THREAD_USES_DATETIME
226 bool timed_lock(system_time const& timeout);
227 template<typename TimeDuration>
228 bool timed_lock(TimeDuration const & relative_time)
230 return timed_lock(get_system_time()+relative_time);
232 bool timed_lock_shared(system_time const& timeout);
233 template<typename TimeDuration>
234 bool timed_lock_shared(TimeDuration const & relative_time)
236 return timed_lock_shared(get_system_time()+relative_time);
241 template <class Clock, class Duration>
243 shared_mutex::try_lock_until(
244 const boost::chrono::time_point<Clock, Duration>& abs_time)
246 boost::unique_lock<mutex_t> lk(mut_);
247 if (state_ & write_entered_)
251 boost::cv_status status = gate1_.wait_until(lk, abs_time);
252 if ((state_ & write_entered_) == 0)
254 if (status == boost::cv_status::timeout)
258 state_ |= write_entered_;
259 if (state_ & n_readers_)
263 boost::cv_status status = gate2_.wait_until(lk, abs_time);
264 if ((state_ & n_readers_) == 0)
266 if (status == boost::cv_status::timeout)
268 state_ &= ~write_entered_;
276 template <class Clock, class Duration>
278 shared_mutex::try_lock_shared_until(
279 const boost::chrono::time_point<Clock, Duration>& abs_time)
281 boost::unique_lock<mutex_t> lk(mut_);
282 if ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_)
286 boost::cv_status status = gate1_.wait_until(lk, abs_time);
287 if ((state_ & write_entered_) == 0 &&
288 (state_ & n_readers_) < n_readers_)
290 if (status == boost::cv_status::timeout)
294 count_t num_readers = (state_ & n_readers_) + 1;
295 state_ &= ~n_readers_;
296 state_ |= num_readers;
300 #if defined BOOST_THREAD_USES_DATETIME
301 bool shared_mutex::timed_lock(system_time const& abs_time)
303 boost::unique_lock<mutex_t> lk(mut_);
304 if (state_ & write_entered_)
308 bool status = gate1_.timed_wait(lk, abs_time);
309 if ((state_ & write_entered_) == 0)
315 state_ |= write_entered_;
316 if (state_ & n_readers_)
320 bool status = gate2_.timed_wait(lk, abs_time);
321 if ((state_ & n_readers_) == 0)
325 state_ &= ~write_entered_;
332 bool shared_mutex::timed_lock_shared(system_time const& abs_time)
334 boost::unique_lock<mutex_t> lk(mut_);
335 if (state_ & write_entered_)
339 bool status = gate1_.timed_wait(lk, abs_time);
340 if ((state_ & write_entered_) == 0)
346 state_ |= write_entered_;
347 if (state_ & n_readers_)
351 bool status = gate2_.timed_wait(lk, abs_time);
352 if ((state_ & n_readers_) == 0)
356 state_ &= ~write_entered_;
366 typedef boost::mutex mutex_t;
367 typedef boost::condition_variable cond_t;
368 typedef unsigned count_t;
375 static const unsigned write_entered_ = 1U << (sizeof(count_t)*CHAR_BIT - 1);
376 static const unsigned upgradable_entered_ = write_entered_ >> 1;
377 static const unsigned n_readers_ = ~(write_entered_ | upgradable_entered_);
381 BOOST_THREAD_INLINE upgrade_mutex();
382 BOOST_THREAD_INLINE ~upgrade_mutex();
384 #ifndef BOOST_CXX11_NO_DELETED_FUNCTIONS
385 upgrade_mutex(const upgrade_mutex&) = delete;
386 upgrade_mutex& operator=(const upgrade_mutex&) = delete;
387 #else // BOOST_CXX11_NO_DELETED_FUNCTIONS
389 upgrade_mutex(const upgrade_mutex&);
390 upgrade_mutex& operator=(const upgrade_mutex&);
392 #endif // BOOST_CXX11_NO_DELETED_FUNCTIONS
394 // Exclusive ownership
396 BOOST_THREAD_INLINE void lock();
397 BOOST_THREAD_INLINE bool try_lock();
398 template <class Rep, class Period>
399 bool try_lock_for(const boost::chrono::duration<Rep, Period>& rel_time)
401 return try_lock_until(boost::chrono::steady_clock::now() + rel_time);
403 template <class Clock, class Duration>
406 const boost::chrono::time_point<Clock, Duration>& abs_time);
407 BOOST_THREAD_INLINE void unlock();
411 BOOST_THREAD_INLINE void lock_shared();
412 BOOST_THREAD_INLINE bool try_lock_shared();
413 template <class Rep, class Period>
415 try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
417 return try_lock_shared_until(boost::chrono::steady_clock::now() +
420 template <class Clock, class Duration>
422 try_lock_shared_until(
423 const boost::chrono::time_point<Clock, Duration>& abs_time);
424 BOOST_THREAD_INLINE void unlock_shared();
428 BOOST_THREAD_INLINE void lock_upgrade();
429 BOOST_THREAD_INLINE bool try_lock_upgrade();
430 template <class Rep, class Period>
432 try_lock_upgrade_for(
433 const boost::chrono::duration<Rep, Period>& rel_time)
435 return try_lock_upgrade_until(boost::chrono::steady_clock::now() +
438 template <class Clock, class Duration>
440 try_lock_upgrade_until(
441 const boost::chrono::time_point<Clock, Duration>& abs_time);
442 BOOST_THREAD_INLINE void unlock_upgrade();
444 // Shared <-> Exclusive
446 BOOST_THREAD_INLINE bool try_unlock_shared_and_lock();
447 template <class Rep, class Period>
449 try_unlock_shared_and_lock_for(
450 const boost::chrono::duration<Rep, Period>& rel_time)
452 return try_unlock_shared_and_lock_until(
453 boost::chrono::steady_clock::now() + rel_time);
455 template <class Clock, class Duration>
457 try_unlock_shared_and_lock_until(
458 const boost::chrono::time_point<Clock, Duration>& abs_time);
459 BOOST_THREAD_INLINE void unlock_and_lock_shared();
461 // Shared <-> Upgrade
463 BOOST_THREAD_INLINE bool try_unlock_shared_and_lock_upgrade();
464 template <class Rep, class Period>
466 try_unlock_shared_and_lock_upgrade_for(
467 const boost::chrono::duration<Rep, Period>& rel_time)
469 return try_unlock_shared_and_lock_upgrade_until(
470 boost::chrono::steady_clock::now() + rel_time);
472 template <class Clock, class Duration>
474 try_unlock_shared_and_lock_upgrade_until(
475 const boost::chrono::time_point<Clock, Duration>& abs_time);
476 BOOST_THREAD_INLINE void unlock_upgrade_and_lock_shared();
478 // Upgrade <-> Exclusive
480 BOOST_THREAD_INLINE void unlock_upgrade_and_lock();
481 BOOST_THREAD_INLINE bool try_unlock_upgrade_and_lock();
482 template <class Rep, class Period>
484 try_unlock_upgrade_and_lock_for(
485 const boost::chrono::duration<Rep, Period>& rel_time)
487 return try_unlock_upgrade_and_lock_until(
488 boost::chrono::steady_clock::now() + rel_time);
490 template <class Clock, class Duration>
492 try_unlock_upgrade_and_lock_until(
493 const boost::chrono::time_point<Clock, Duration>& abs_time);
494 BOOST_THREAD_INLINE void unlock_and_lock_upgrade();
496 #if defined BOOST_THREAD_USES_DATETIME
497 inline bool timed_lock(system_time const& abs_time);
498 template<typename TimeDuration>
499 bool timed_lock(TimeDuration const & relative_time)
501 return timed_lock(get_system_time()+relative_time);
503 inline bool timed_lock_shared(system_time const& abs_time);
504 template<typename TimeDuration>
505 bool timed_lock_shared(TimeDuration const & relative_time)
507 return timed_lock_shared(get_system_time()+relative_time);
509 inline bool timed_lock_upgrade(system_time const& abs_time);
510 template<typename TimeDuration>
511 bool timed_lock_upgrade(TimeDuration const & relative_time)
513 return timed_lock_upgrade(get_system_time()+relative_time);
519 template <class Clock, class Duration>
521 upgrade_mutex::try_lock_until(
522 const boost::chrono::time_point<Clock, Duration>& abs_time)
524 boost::unique_lock<mutex_t> lk(mut_);
525 if (state_ & (write_entered_ | upgradable_entered_))
529 boost::cv_status status = gate1_.wait_until(lk, abs_time);
530 if ((state_ & (write_entered_ | upgradable_entered_)) == 0)
532 if (status == boost::cv_status::timeout)
536 state_ |= write_entered_;
537 if (state_ & n_readers_)
541 boost::cv_status status = gate2_.wait_until(lk, abs_time);
542 if ((state_ & n_readers_) == 0)
544 if (status == boost::cv_status::timeout)
546 state_ &= ~write_entered_;
554 template <class Clock, class Duration>
556 upgrade_mutex::try_lock_shared_until(
557 const boost::chrono::time_point<Clock, Duration>& abs_time)
559 boost::unique_lock<mutex_t> lk(mut_);
560 if ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_)
564 boost::cv_status status = gate1_.wait_until(lk, abs_time);
565 if ((state_ & write_entered_) == 0 &&
566 (state_ & n_readers_) < n_readers_)
568 if (status == boost::cv_status::timeout)
572 count_t num_readers = (state_ & n_readers_) + 1;
573 state_ &= ~n_readers_;
574 state_ |= num_readers;
578 template <class Clock, class Duration>
580 upgrade_mutex::try_lock_upgrade_until(
581 const boost::chrono::time_point<Clock, Duration>& abs_time)
583 boost::unique_lock<mutex_t> lk(mut_);
584 if ((state_ & (write_entered_ | upgradable_entered_)) ||
585 (state_ & n_readers_) == n_readers_)
589 boost::cv_status status = gate1_.wait_until(lk, abs_time);
590 if ((state_ & (write_entered_ | upgradable_entered_)) == 0 &&
591 (state_ & n_readers_) < n_readers_)
593 if (status == boost::cv_status::timeout)
597 count_t num_readers = (state_ & n_readers_) + 1;
598 state_ &= ~n_readers_;
599 state_ |= upgradable_entered_ | num_readers;
603 #if defined BOOST_THREAD_USES_DATETIME
604 bool upgrade_mutex::timed_lock(system_time const& abs_time)
606 boost::unique_lock<mutex_t> lk(mut_);
607 if (state_ & (write_entered_ | upgradable_entered_))
611 bool status = gate1_.timed_wait(lk, abs_time);
612 if ((state_ & (write_entered_ | upgradable_entered_)) == 0)
618 state_ |= write_entered_;
619 if (state_ & n_readers_)
623 bool status = gate2_.timed_wait(lk, abs_time);
624 if ((state_ & n_readers_) == 0)
628 state_ &= ~write_entered_;
635 bool upgrade_mutex::timed_lock_shared(system_time const& abs_time)
637 boost::unique_lock<mutex_t> lk(mut_);
638 if ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_)
642 bool status = gate1_.timed_wait(lk, abs_time);
643 if ((state_ & write_entered_) == 0 &&
644 (state_ & n_readers_) < n_readers_)
650 count_t num_readers = (state_ & n_readers_) + 1;
651 state_ &= ~n_readers_;
652 state_ |= num_readers;
655 bool upgrade_mutex::timed_lock_upgrade(system_time const& abs_time)
657 boost::unique_lock<mutex_t> lk(mut_);
658 if ((state_ & (write_entered_ | upgradable_entered_)) ||
659 (state_ & n_readers_) == n_readers_)
663 bool status = gate1_.timed_wait(lk, abs_time);
664 if ((state_ & (write_entered_ | upgradable_entered_)) == 0 &&
665 (state_ & n_readers_) < n_readers_)
671 count_t num_readers = (state_ & n_readers_) + 1;
672 state_ &= ~n_readers_;
673 state_ |= upgradable_entered_ | num_readers;
678 template <class Clock, class Duration>
680 upgrade_mutex::try_unlock_shared_and_lock_until(
681 const boost::chrono::time_point<Clock, Duration>& abs_time)
683 boost::unique_lock<mutex_t> lk(mut_);
688 boost::cv_status status = gate2_.wait_until(lk, abs_time);
691 if (status == boost::cv_status::timeout)
695 state_ = write_entered_;
699 template <class Clock, class Duration>
701 upgrade_mutex::try_unlock_shared_and_lock_upgrade_until(
702 const boost::chrono::time_point<Clock, Duration>& abs_time)
704 boost::unique_lock<mutex_t> lk(mut_);
705 if ((state_ & (write_entered_ | upgradable_entered_)) != 0)
709 boost::cv_status status = gate2_.wait_until(lk, abs_time);
710 if ((state_ & (write_entered_ | upgradable_entered_)) == 0)
712 if (status == boost::cv_status::timeout)
716 state_ |= upgradable_entered_;
720 template <class Clock, class Duration>
722 upgrade_mutex::try_unlock_upgrade_and_lock_until(
723 const boost::chrono::time_point<Clock, Duration>& abs_time)
725 boost::unique_lock<mutex_t> lk(mut_);
726 if ((state_ & n_readers_) != 1)
730 boost::cv_status status = gate2_.wait_until(lk, abs_time);
731 if ((state_ & n_readers_) == 1)
733 if (status == boost::cv_status::timeout)
737 state_ = write_entered_;
744 shared_mutex::shared_mutex()
749 shared_mutex::~shared_mutex()
751 boost::lock_guard<mutex_t> _(mut_);
754 // Exclusive ownership
759 boost::unique_lock<mutex_t> lk(mut_);
760 while (state_ & write_entered_)
762 state_ |= write_entered_;
763 while (state_ & n_readers_)
768 shared_mutex::try_lock()
770 boost::unique_lock<mutex_t> lk(mut_);
773 state_ = write_entered_;
780 shared_mutex::unlock()
782 boost::lock_guard<mutex_t> _(mut_);
790 shared_mutex::lock_shared()
792 boost::unique_lock<mutex_t> lk(mut_);
793 while ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_)
795 count_t num_readers = (state_ & n_readers_) + 1;
796 state_ &= ~n_readers_;
797 state_ |= num_readers;
801 shared_mutex::try_lock_shared()
803 boost::unique_lock<mutex_t> lk(mut_);
804 count_t num_readers = state_ & n_readers_;
805 if (!(state_ & write_entered_) && num_readers != n_readers_)
808 state_ &= ~n_readers_;
809 state_ |= num_readers;
816 shared_mutex::unlock_shared()
818 boost::lock_guard<mutex_t> _(mut_);
819 count_t num_readers = (state_ & n_readers_) - 1;
820 state_ &= ~n_readers_;
821 state_ |= num_readers;
822 if (state_ & write_entered_)
824 if (num_readers == 0)
829 if (num_readers == n_readers_ - 1)
836 upgrade_mutex::upgrade_mutex()
843 upgrade_mutex::~upgrade_mutex()
845 boost::lock_guard<mutex_t> _(mut_);
848 // Exclusive ownership
851 upgrade_mutex::lock()
853 boost::unique_lock<mutex_t> lk(mut_);
854 while (state_ & (write_entered_ | upgradable_entered_))
856 state_ |= write_entered_;
857 while (state_ & n_readers_)
862 upgrade_mutex::try_lock()
864 boost::unique_lock<mutex_t> lk(mut_);
867 state_ = write_entered_;
874 upgrade_mutex::unlock()
876 boost::lock_guard<mutex_t> _(mut_);
884 upgrade_mutex::lock_shared()
886 boost::unique_lock<mutex_t> lk(mut_);
887 while ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_)
889 count_t num_readers = (state_ & n_readers_) + 1;
890 state_ &= ~n_readers_;
891 state_ |= num_readers;
895 upgrade_mutex::try_lock_shared()
897 boost::unique_lock<mutex_t> lk(mut_);
898 count_t num_readers = state_ & n_readers_;
899 if (!(state_ & write_entered_) && num_readers != n_readers_)
902 state_ &= ~n_readers_;
903 state_ |= num_readers;
910 upgrade_mutex::unlock_shared()
912 boost::lock_guard<mutex_t> _(mut_);
913 count_t num_readers = (state_ & n_readers_) - 1;
914 state_ &= ~n_readers_;
915 state_ |= num_readers;
916 if (state_ & write_entered_)
918 if (num_readers == 0)
923 if (num_readers == n_readers_ - 1)
931 upgrade_mutex::lock_upgrade()
933 boost::unique_lock<mutex_t> lk(mut_);
934 while ((state_ & (write_entered_ | upgradable_entered_)) ||
935 (state_ & n_readers_) == n_readers_)
937 count_t num_readers = (state_ & n_readers_) + 1;
938 state_ &= ~n_readers_;
939 state_ |= upgradable_entered_ | num_readers;
943 upgrade_mutex::try_lock_upgrade()
945 boost::unique_lock<mutex_t> lk(mut_);
946 count_t num_readers = state_ & n_readers_;
947 if (!(state_ & (write_entered_ | upgradable_entered_))
948 && num_readers != n_readers_)
951 state_ &= ~n_readers_;
952 state_ |= upgradable_entered_ | num_readers;
959 upgrade_mutex::unlock_upgrade()
962 boost::lock_guard<mutex_t> _(mut_);
963 count_t num_readers = (state_ & n_readers_) - 1;
964 state_ &= ~(upgradable_entered_ | n_readers_);
965 state_ |= num_readers;
970 // Shared <-> Exclusive
973 upgrade_mutex::try_unlock_shared_and_lock()
975 boost::unique_lock<mutex_t> lk(mut_);
978 state_ = write_entered_;
985 upgrade_mutex::unlock_and_lock_shared()
988 boost::lock_guard<mutex_t> _(mut_);
994 // Shared <-> Upgrade
997 upgrade_mutex::try_unlock_shared_and_lock_upgrade()
999 boost::unique_lock<mutex_t> lk(mut_);
1000 if (!(state_ & (write_entered_ | upgradable_entered_)))
1002 state_ |= upgradable_entered_;
1009 upgrade_mutex::unlock_upgrade_and_lock_shared()
1012 boost::lock_guard<mutex_t> _(mut_);
1013 state_ &= ~upgradable_entered_;
1015 gate1_.notify_all();
1018 // Upgrade <-> Exclusive
1021 upgrade_mutex::unlock_upgrade_and_lock()
1023 boost::unique_lock<mutex_t> lk(mut_);
1024 count_t num_readers = (state_ & n_readers_) - 1;
1025 state_ &= ~(upgradable_entered_ | n_readers_);
1026 state_ |= write_entered_ | num_readers;
1027 while (state_ & n_readers_)
1032 upgrade_mutex::try_unlock_upgrade_and_lock()
1034 boost::unique_lock<mutex_t> lk(mut_);
1035 if (state_ == (upgradable_entered_ | 1))
1037 state_ = write_entered_;
1044 upgrade_mutex::unlock_and_lock_upgrade()
1047 boost::lock_guard<mutex_t> _(mut_);
1048 state_ = upgradable_entered_ | 1;
1050 gate1_.notify_all();
1057 //using thread_v2::shared_mutex;
1058 using thread_v2::upgrade_mutex;
1059 typedef thread_v2::upgrade_mutex shared_mutex;