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 // based on boost::interprocess::sync::interprocess_spinlock
9 #ifndef BOOST_FIBERS_RECURSIVE_MUTEX_H
10 #define BOOST_FIBERS_RECURSIVE_MUTEX_H
14 #include <boost/config.hpp>
16 #include <boost/assert.hpp>
18 #include <boost/fiber/context.hpp>
19 #include <boost/fiber/detail/config.hpp>
20 #include <boost/fiber/detail/spinlock.hpp>
22 #ifdef BOOST_HAS_ABI_HEADERS
23 # include BOOST_ABI_PREFIX
27 # pragma warning(push)
28 # pragma warning(disable:4251)
34 class condition_variable;
36 class BOOST_FIBERS_DECL recursive_mutex {
38 friend class condition_variable;
40 typedef context::wait_queue_t wait_queue_type;
42 detail::spinlock wait_queue_splk_{};
43 wait_queue_type wait_queue_{};
44 context * owner_{ nullptr };
45 std::size_t count_{ 0 };
48 recursive_mutex() = default;
51 BOOST_ASSERT( nullptr == owner_);
52 BOOST_ASSERT( 0 == count_);
53 BOOST_ASSERT( wait_queue_.empty() );
56 recursive_mutex( recursive_mutex const&) = delete;
57 recursive_mutex & operator=( recursive_mutex const&) = delete;
61 bool try_lock() noexcept;
72 #ifdef BOOST_HAS_ABI_HEADERS
73 # include BOOST_ABI_SUFFIX
76 #endif // BOOST_FIBERS_RECURSIVE_MUTEX_H