]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/src/recursive_mutex.cpp
d04680cb62ed6692c37d49b60aa052cd9d8f5946
2 // Copyright Oliver Kowalke 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #include "boost/fiber/recursive_mutex.hpp"
12 #include "boost/fiber/exceptions.hpp"
13 #include "boost/fiber/scheduler.hpp"
15 #ifdef BOOST_HAS_ABI_HEADERS
16 # include BOOST_ABI_PREFIX
23 recursive_mutex::lock() {
24 context
* ctx
= context::active();
25 // store this fiber in order to be notified later
26 detail::spinlock_lock
lk( wait_queue_splk_
);
30 } else if ( nullptr == owner_
) {
35 BOOST_ASSERT( ! ctx
->wait_is_linked() );
36 ctx
->wait_link( wait_queue_
);
39 BOOST_ASSERT( ! ctx
->wait_is_linked() );
43 recursive_mutex::try_lock() noexcept
{
44 context
* ctx
= context::active();
45 detail::spinlock_lock
lk( wait_queue_splk_
);
46 if ( nullptr == owner_
) {
49 } else if ( ctx
== owner_
) {
53 // let other fiber release the lock
54 context::active()->yield();
59 recursive_mutex::unlock() {
60 context
* ctx
= context::active();
61 detail::spinlock_lock
lk( wait_queue_splk_
);
64 std::make_error_code( std::errc::operation_not_permitted
),
65 "boost fiber: no privilege to perform the operation");
68 if ( ! wait_queue_
.empty() ) {
69 context
* ctx
= & wait_queue_
.front();
70 wait_queue_
.pop_front();
73 context::active()->set_ready( ctx
);
83 #ifdef BOOST_HAS_ABI_HEADERS
84 # include BOOST_ABI_SUFFIX