1 // <shared_mutex> -*- C++ -*-
3 // Copyright (C) 2013-2022 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file include/shared_mutex
26 * This is a Standard C++ Library header.
29 #ifndef _GLIBCXX_SHARED_MUTEX
30 #define _GLIBCXX_SHARED_MUTEX 1
32 #pragma GCC system_header
34 #if __cplusplus >= 201402L
36 #include <bits/chrono.h>
37 #include <bits/functexcept.h>
38 #include <bits/move.h> // move, __exchange
39 #include <bits/std_mutex.h> // defer_lock_t
41 #if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK)
42 # include <condition_variable>
45 namespace std _GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
54 #ifdef _GLIBCXX_HAS_GTHREADS
56 #if __cplusplus >= 201703L
57 #define __cpp_lib_shared_mutex 201505L
61 #define __cpp_lib_shared_timed_mutex 201402L
62 class shared_timed_mutex;
64 /// @cond undocumented
66 #if _GLIBCXX_USE_PTHREAD_RWLOCK_T
68 #define _GLIBCXX_GTHRW(name) \
69 __gthrw(pthread_ ## name); \
71 __glibcxx_ ## name (pthread_rwlock_t *__rwlock) \
73 if (__gthread_active_p ()) \
74 return __gthrw_(pthread_ ## name) (__rwlock); \
78 _GLIBCXX_GTHRW(rwlock_rdlock)
79 _GLIBCXX_GTHRW(rwlock_tryrdlock)
80 _GLIBCXX_GTHRW(rwlock_wrlock)
81 _GLIBCXX_GTHRW(rwlock_trywrlock)
82 _GLIBCXX_GTHRW(rwlock_unlock)
83 # ifndef PTHREAD_RWLOCK_INITIALIZER
84 _GLIBCXX_GTHRW(rwlock_destroy)
85 __gthrw(pthread_rwlock_init);
87 __glibcxx_rwlock_init (pthread_rwlock_t *__rwlock)
89 if (__gthread_active_p ())
90 return __gthrw_(pthread_rwlock_init) (__rwlock, NULL);
95 # if _GTHREAD_USE_MUTEX_TIMEDLOCK
96 __gthrw(pthread_rwlock_timedrdlock);
98 __glibcxx_rwlock_timedrdlock (pthread_rwlock_t *__rwlock,
101 if (__gthread_active_p ())
102 return __gthrw_(pthread_rwlock_timedrdlock) (__rwlock, __ts);
106 __gthrw(pthread_rwlock_timedwrlock);
108 __glibcxx_rwlock_timedwrlock (pthread_rwlock_t *__rwlock,
109 const timespec *__ts)
111 if (__gthread_active_p ())
112 return __gthrw_(pthread_rwlock_timedwrlock) (__rwlock, __ts);
119 __glibcxx_rwlock_rdlock (pthread_rwlock_t *__rwlock)
120 { return pthread_rwlock_rdlock (__rwlock); }
122 __glibcxx_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
123 { return pthread_rwlock_tryrdlock (__rwlock); }
125 __glibcxx_rwlock_wrlock (pthread_rwlock_t *__rwlock)
126 { return pthread_rwlock_wrlock (__rwlock); }
128 __glibcxx_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
129 { return pthread_rwlock_trywrlock (__rwlock); }
131 __glibcxx_rwlock_unlock (pthread_rwlock_t *__rwlock)
132 { return pthread_rwlock_unlock (__rwlock); }
134 __glibcxx_rwlock_destroy(pthread_rwlock_t *__rwlock)
135 { return pthread_rwlock_destroy (__rwlock); }
137 __glibcxx_rwlock_init(pthread_rwlock_t *__rwlock)
138 { return pthread_rwlock_init (__rwlock, NULL); }
139 # if _GTHREAD_USE_MUTEX_TIMEDLOCK
141 __glibcxx_rwlock_timedrdlock (pthread_rwlock_t *__rwlock,
142 const timespec *__ts)
143 { return pthread_rwlock_timedrdlock (__rwlock, __ts); }
145 __glibcxx_rwlock_timedwrlock (pthread_rwlock_t *__rwlock,
146 const timespec *__ts)
147 { return pthread_rwlock_timedwrlock (__rwlock, __ts); }
151 /// A shared mutex type implemented using pthread_rwlock_t.
152 class __shared_mutex_pthread
154 friend class shared_timed_mutex;
156 #ifdef PTHREAD_RWLOCK_INITIALIZER
157 pthread_rwlock_t _M_rwlock = PTHREAD_RWLOCK_INITIALIZER;
160 __shared_mutex_pthread() = default;
161 ~__shared_mutex_pthread() = default;
163 pthread_rwlock_t _M_rwlock;
166 __shared_mutex_pthread()
168 int __ret = __glibcxx_rwlock_init(&_M_rwlock);
171 else if (__ret == EAGAIN)
172 __throw_system_error(int(errc::resource_unavailable_try_again));
173 else if (__ret == EPERM)
174 __throw_system_error(int(errc::operation_not_permitted));
175 // Errors not handled: EBUSY, EINVAL
176 __glibcxx_assert(__ret == 0);
179 ~__shared_mutex_pthread()
181 int __ret __attribute((__unused__)) = __glibcxx_rwlock_destroy(&_M_rwlock);
182 // Errors not handled: EBUSY, EINVAL
183 __glibcxx_assert(__ret == 0);
187 __shared_mutex_pthread(const __shared_mutex_pthread&) = delete;
188 __shared_mutex_pthread& operator=(const __shared_mutex_pthread&) = delete;
193 int __ret = __glibcxx_rwlock_wrlock(&_M_rwlock);
194 if (__ret == EDEADLK)
195 __throw_system_error(int(errc::resource_deadlock_would_occur));
196 // Errors not handled: EINVAL
197 __glibcxx_assert(__ret == 0);
203 int __ret = __glibcxx_rwlock_trywrlock(&_M_rwlock);
204 if (__ret == EBUSY) return false;
205 // Errors not handled: EINVAL
206 __glibcxx_assert(__ret == 0);
213 int __ret __attribute((__unused__)) = __glibcxx_rwlock_unlock(&_M_rwlock);
214 // Errors not handled: EPERM, EBUSY, EINVAL
215 __glibcxx_assert(__ret == 0);
224 // We retry if we exceeded the maximum number of read locks supported by
225 // the POSIX implementation; this can result in busy-waiting, but this
226 // is okay based on the current specification of forward progress
227 // guarantees by the standard.
229 __ret = __glibcxx_rwlock_rdlock(&_M_rwlock);
230 while (__ret == EAGAIN);
231 if (__ret == EDEADLK)
232 __throw_system_error(int(errc::resource_deadlock_would_occur));
233 // Errors not handled: EINVAL
234 __glibcxx_assert(__ret == 0);
240 int __ret = __glibcxx_rwlock_tryrdlock(&_M_rwlock);
241 // If the maximum number of read locks has been exceeded, we just fail
242 // to acquire the lock. Unlike for lock(), we are not allowed to throw
244 if (__ret == EBUSY || __ret == EAGAIN) return false;
245 // Errors not handled: EINVAL
246 __glibcxx_assert(__ret == 0);
256 void* native_handle() { return &_M_rwlock; }
260 #if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK)
261 /// A shared mutex type implemented using std::condition_variable.
262 class __shared_mutex_cv
264 friend class shared_timed_mutex;
266 // Based on Howard Hinnant's reference implementation from N2406.
268 // The high bit of _M_state is the write-entered flag which is set to
269 // indicate a writer has taken the lock or is queuing to take the lock.
270 // The remaining bits are the count of reader locks.
272 // To take a reader lock, block on gate1 while the write-entered flag is
273 // set or the maximum number of reader locks is held, then increment the
274 // reader lock count.
275 // To release, decrement the count, then if the write-entered flag is set
276 // and the count is zero then signal gate2 to wake a queued writer,
277 // otherwise if the maximum number of reader locks was held signal gate1
280 // To take a writer lock, block on gate1 while the write-entered flag is
281 // set, then set the write-entered flag to start queueing, then block on
282 // gate2 while the number of reader locks is non-zero.
283 // To release, unset the write-entered flag and signal gate1 to wake all
284 // blocked readers and writers.
286 // This means that when no reader locks are held readers and writers get
287 // equal priority. When one or more reader locks is held a writer gets
288 // priority and no more reader locks can be taken while the writer is
291 // Only locked when accessing _M_state or waiting on condition variables.
293 // Used to block while write-entered is set or reader count at maximum.
294 condition_variable _M_gate1;
295 // Used to block queued writers while reader count is non-zero.
296 condition_variable _M_gate2;
297 // The write-entered flag and reader count.
300 static constexpr unsigned _S_write_entered
301 = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
302 static constexpr unsigned _S_max_readers = ~_S_write_entered;
304 // Test whether the write-entered flag is set. _M_mut must be locked.
305 bool _M_write_entered() const { return _M_state & _S_write_entered; }
307 // The number of reader locks currently held. _M_mut must be locked.
308 unsigned _M_readers() const { return _M_state & _S_max_readers; }
311 __shared_mutex_cv() : _M_state(0) {}
315 __glibcxx_assert( _M_state == 0 );
318 __shared_mutex_cv(const __shared_mutex_cv&) = delete;
319 __shared_mutex_cv& operator=(const __shared_mutex_cv&) = delete;
321 // Exclusive ownership
326 unique_lock<mutex> __lk(_M_mut);
327 // Wait until we can set the write-entered flag.
328 _M_gate1.wait(__lk, [=]{ return !_M_write_entered(); });
329 _M_state |= _S_write_entered;
330 // Then wait until there are no more readers.
331 _M_gate2.wait(__lk, [=]{ return _M_readers() == 0; });
337 unique_lock<mutex> __lk(_M_mut, try_to_lock);
338 if (__lk.owns_lock() && _M_state == 0)
340 _M_state = _S_write_entered;
349 lock_guard<mutex> __lk(_M_mut);
350 __glibcxx_assert( _M_write_entered() );
352 // call notify_all() while mutex is held so that another thread can't
353 // lock and unlock the mutex then destroy *this before we make the call.
354 _M_gate1.notify_all();
362 unique_lock<mutex> __lk(_M_mut);
363 _M_gate1.wait(__lk, [=]{ return _M_state < _S_max_readers; });
370 unique_lock<mutex> __lk(_M_mut, try_to_lock);
371 if (!__lk.owns_lock())
373 if (_M_state < _S_max_readers)
384 lock_guard<mutex> __lk(_M_mut);
385 __glibcxx_assert( _M_readers() > 0 );
386 auto __prev = _M_state--;
387 if (_M_write_entered())
389 // Wake the queued writer if there are no more readers.
390 if (_M_readers() == 0)
391 _M_gate2.notify_one();
392 // No need to notify gate1 because we give priority to the queued
393 // writer, and that writer will eventually notify gate1 after it
394 // clears the write-entered flag.
398 // Wake any thread that was blocked on reader overflow.
399 if (__prev == _S_max_readers)
400 _M_gate1.notify_one();
407 #if __cplusplus >= 201703L
408 /// The standard shared mutex type.
412 shared_mutex() = default;
413 ~shared_mutex() = default;
415 shared_mutex(const shared_mutex&) = delete;
416 shared_mutex& operator=(const shared_mutex&) = delete;
418 // Exclusive ownership
420 void lock() { _M_impl.lock(); }
421 bool try_lock() { return _M_impl.try_lock(); }
422 void unlock() { _M_impl.unlock(); }
426 void lock_shared() { _M_impl.lock_shared(); }
427 bool try_lock_shared() { return _M_impl.try_lock_shared(); }
428 void unlock_shared() { _M_impl.unlock_shared(); }
430 #if _GLIBCXX_USE_PTHREAD_RWLOCK_T
431 typedef void* native_handle_type;
432 native_handle_type native_handle() { return _M_impl.native_handle(); }
435 __shared_mutex_pthread _M_impl;
438 __shared_mutex_cv _M_impl;
443 /// @cond undocumented
444 #if _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK
445 using __shared_timed_mutex_base = __shared_mutex_pthread;
447 using __shared_timed_mutex_base = __shared_mutex_cv;
451 /// The standard shared timed mutex type.
452 class shared_timed_mutex
453 : private __shared_timed_mutex_base
455 using _Base = __shared_timed_mutex_base;
457 // Must use the same clock as condition_variable for __shared_mutex_cv.
458 #ifdef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK
459 using __clock_t = chrono::steady_clock;
461 using __clock_t = chrono::system_clock;
465 shared_timed_mutex() = default;
466 ~shared_timed_mutex() = default;
468 shared_timed_mutex(const shared_timed_mutex&) = delete;
469 shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
471 // Exclusive ownership
473 void lock() { _Base::lock(); }
474 bool try_lock() { return _Base::try_lock(); }
475 void unlock() { _Base::unlock(); }
477 template<typename _Rep, typename _Period>
479 try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
481 auto __rt = chrono::duration_cast<__clock_t::duration>(__rtime);
482 if (ratio_greater<__clock_t::period, _Period>())
484 return try_lock_until(__clock_t::now() + __rt);
489 void lock_shared() { _Base::lock_shared(); }
490 bool try_lock_shared() { return _Base::try_lock_shared(); }
491 void unlock_shared() { _Base::unlock_shared(); }
493 template<typename _Rep, typename _Period>
495 try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rtime)
497 auto __rt = chrono::duration_cast<__clock_t::duration>(__rtime);
498 if (ratio_greater<__clock_t::period, _Period>())
500 return try_lock_shared_until(__clock_t::now() + __rt);
503 #if _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK
505 // Exclusive ownership
507 template<typename _Duration>
509 try_lock_until(const chrono::time_point<chrono::system_clock,
512 auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
513 auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
515 __gthread_time_t __ts =
517 static_cast<std::time_t>(__s.time_since_epoch().count()),
518 static_cast<long>(__ns.count())
521 int __ret = __glibcxx_rwlock_timedwrlock(&_M_rwlock, &__ts);
522 // On self-deadlock, we just fail to acquire the lock. Technically,
523 // the program violated the precondition.
524 if (__ret == ETIMEDOUT || __ret == EDEADLK)
526 // Errors not handled: EINVAL
527 __glibcxx_assert(__ret == 0);
531 #ifdef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK
532 template<typename _Duration>
534 try_lock_until(const chrono::time_point<chrono::steady_clock,
537 auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
538 auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
540 __gthread_time_t __ts =
542 static_cast<std::time_t>(__s.time_since_epoch().count()),
543 static_cast<long>(__ns.count())
546 int __ret = pthread_rwlock_clockwrlock(&_M_rwlock, CLOCK_MONOTONIC,
548 // On self-deadlock, we just fail to acquire the lock. Technically,
549 // the program violated the precondition.
550 if (__ret == ETIMEDOUT || __ret == EDEADLK)
552 // Errors not handled: EINVAL
553 __glibcxx_assert(__ret == 0);
558 template<typename _Clock, typename _Duration>
560 try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
562 #if __cplusplus > 201703L
563 static_assert(chrono::is_clock_v<_Clock>);
565 // The user-supplied clock may not tick at the same rate as
566 // steady_clock, so we must loop in order to guarantee that
567 // the timeout has expired before returning false.
568 typename _Clock::time_point __now = _Clock::now();
570 auto __rtime = __atime - __now;
571 if (try_lock_for(__rtime))
573 __now = _Clock::now();
574 } while (__atime > __now);
580 template<typename _Duration>
582 try_lock_shared_until(const chrono::time_point<chrono::system_clock,
585 auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
586 auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
588 __gthread_time_t __ts =
590 static_cast<std::time_t>(__s.time_since_epoch().count()),
591 static_cast<long>(__ns.count())
595 // Unlike for lock(), we are not allowed to throw an exception so if
596 // the maximum number of read locks has been exceeded, or we would
597 // deadlock, we just try to acquire the lock again (and will time out
599 // In cases where we would exceed the maximum number of read locks
600 // throughout the whole time until the timeout, we will fail to
601 // acquire the lock even if it would be logically free; however, this
602 // is allowed by the standard, and we made a "strong effort"
603 // (see C++14 30.4.1.4p26).
604 // For cases where the implementation detects a deadlock we
605 // intentionally block and timeout so that an early return isn't
606 // mistaken for a spurious failure, which might help users realise
607 // there is a deadlock.
609 __ret = __glibcxx_rwlock_timedrdlock(&_M_rwlock, &__ts);
610 while (__ret == EAGAIN || __ret == EDEADLK);
611 if (__ret == ETIMEDOUT)
613 // Errors not handled: EINVAL
614 __glibcxx_assert(__ret == 0);
618 #ifdef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK
619 template<typename _Duration>
621 try_lock_shared_until(const chrono::time_point<chrono::steady_clock,
624 auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
625 auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
627 __gthread_time_t __ts =
629 static_cast<std::time_t>(__s.time_since_epoch().count()),
630 static_cast<long>(__ns.count())
633 int __ret = pthread_rwlock_clockrdlock(&_M_rwlock, CLOCK_MONOTONIC,
635 // On self-deadlock, we just fail to acquire the lock. Technically,
636 // the program violated the precondition.
637 if (__ret == ETIMEDOUT || __ret == EDEADLK)
639 // Errors not handled: EINVAL
640 __glibcxx_assert(__ret == 0);
645 template<typename _Clock, typename _Duration>
647 try_lock_shared_until(const chrono::time_point<_Clock,
650 #if __cplusplus > 201703L
651 static_assert(chrono::is_clock_v<_Clock>);
653 // The user-supplied clock may not tick at the same rate as
654 // steady_clock, so we must loop in order to guarantee that
655 // the timeout has expired before returning false.
656 typename _Clock::time_point __now = _Clock::now();
658 auto __rtime = __atime - __now;
659 if (try_lock_shared_for(__rtime))
661 __now = _Clock::now();
662 } while (__atime > __now);
666 #else // ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK)
668 // Exclusive ownership
670 template<typename _Clock, typename _Duration>
672 try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
674 unique_lock<mutex> __lk(_M_mut);
675 if (!_M_gate1.wait_until(__lk, __abs_time,
676 [=]{ return !_M_write_entered(); }))
680 _M_state |= _S_write_entered;
681 if (!_M_gate2.wait_until(__lk, __abs_time,
682 [=]{ return _M_readers() == 0; }))
684 _M_state ^= _S_write_entered;
685 // Wake all threads blocked while the write-entered flag was set.
686 _M_gate1.notify_all();
694 template <typename _Clock, typename _Duration>
696 try_lock_shared_until(const chrono::time_point<_Clock,
697 _Duration>& __abs_time)
699 unique_lock<mutex> __lk(_M_mut);
700 if (!_M_gate1.wait_until(__lk, __abs_time,
701 [=]{ return _M_state < _S_max_readers; }))
709 #endif // _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK
711 #endif // _GLIBCXX_HAS_GTHREADS
714 template<typename _Mutex>
718 typedef _Mutex mutex_type;
722 shared_lock() noexcept : _M_pm(nullptr), _M_owns(false) { }
725 shared_lock(mutex_type& __m)
726 : _M_pm(std::__addressof(__m)), _M_owns(true)
727 { __m.lock_shared(); }
729 shared_lock(mutex_type& __m, defer_lock_t) noexcept
730 : _M_pm(std::__addressof(__m)), _M_owns(false) { }
732 shared_lock(mutex_type& __m, try_to_lock_t)
733 : _M_pm(std::__addressof(__m)), _M_owns(__m.try_lock_shared()) { }
735 shared_lock(mutex_type& __m, adopt_lock_t)
736 : _M_pm(std::__addressof(__m)), _M_owns(true) { }
738 template<typename _Clock, typename _Duration>
739 shared_lock(mutex_type& __m,
740 const chrono::time_point<_Clock, _Duration>& __abs_time)
741 : _M_pm(std::__addressof(__m)),
742 _M_owns(__m.try_lock_shared_until(__abs_time)) { }
744 template<typename _Rep, typename _Period>
745 shared_lock(mutex_type& __m,
746 const chrono::duration<_Rep, _Period>& __rel_time)
747 : _M_pm(std::__addressof(__m)),
748 _M_owns(__m.try_lock_shared_for(__rel_time)) { }
753 _M_pm->unlock_shared();
756 shared_lock(shared_lock const&) = delete;
757 shared_lock& operator=(shared_lock const&) = delete;
759 shared_lock(shared_lock&& __sl) noexcept : shared_lock()
763 operator=(shared_lock&& __sl) noexcept
765 shared_lock(std::move(__sl)).swap(*this);
773 _M_pm->lock_shared();
781 return _M_owns = _M_pm->try_lock_shared();
784 template<typename _Rep, typename _Period>
786 try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
789 return _M_owns = _M_pm->try_lock_shared_for(__rel_time);
792 template<typename _Clock, typename _Duration>
794 try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
797 return _M_owns = _M_pm->try_lock_shared_until(__abs_time);
804 __throw_system_error(int(errc::resource_deadlock_would_occur));
805 _M_pm->unlock_shared();
812 swap(shared_lock& __u) noexcept
814 std::swap(_M_pm, __u._M_pm);
815 std::swap(_M_owns, __u._M_owns);
822 return std::__exchange(_M_pm, nullptr);
827 bool owns_lock() const noexcept { return _M_owns; }
829 explicit operator bool() const noexcept { return _M_owns; }
831 mutex_type* mutex() const noexcept { return _M_pm; }
837 if (_M_pm == nullptr)
838 __throw_system_error(int(errc::operation_not_permitted));
840 __throw_system_error(int(errc::resource_deadlock_would_occur));
847 /// Swap specialization for shared_lock
848 /// @relates shared_mutex
849 template<typename _Mutex>
851 swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
855 _GLIBCXX_END_NAMESPACE_VERSION
860 #endif // _GLIBCXX_SHARED_MUTEX