| 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 | |
| 9 | using boost::unordered::detail::foa::rw_spinlock; |
| 10 | |
| 11 | static rw_spinlock sp; |
| 12 | static rw_spinlock sp2; |
| 13 | |
| 14 | int 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 |
