1// Copyright 2023 Peter Dimov
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#include <boost/unordered/detail/foa/rw_spinlock.hpp>
6#include <boost/compat/shared_lock.hpp>
7#include <mutex>
8
9using boost::unordered::detail::foa::rw_spinlock;
10
11static rw_spinlock sp;
12static rw_spinlock sp2;
13
14int main()
15{
16 sp.lock();
17 sp2.lock_shared();
18 sp2.lock_shared();
19
20 sp.unlock();
21 sp2.unlock_shared();
22 sp2.unlock_shared();
23
24 {
25 std::lock_guard<rw_spinlock> lock( sp );
26 boost::compat::shared_lock<rw_spinlock> lock2( sp2 );
27 boost::compat::shared_lock<rw_spinlock> lock3( sp2 );
28 }
29}
30

source code of boost/libs/unordered/test/cfoa/rw_spinlock_test4.cpp