]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
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) | |
6 | ||
7 | #ifndef BOOST_FIBERS_MUTEX_H | |
8 | #define BOOST_FIBERS_MUTEX_H | |
9 | ||
10 | #include <boost/config.hpp> | |
11 | ||
12 | #include <boost/assert.hpp> | |
13 | ||
14 | #include <boost/fiber/context.hpp> | |
15 | #include <boost/fiber/detail/config.hpp> | |
16 | #include <boost/fiber/detail/spinlock.hpp> | |
20effc67 | 17 | #include <boost/fiber/waker.hpp> |
7c673cae FG |
18 | |
19 | #ifdef BOOST_HAS_ABI_HEADERS | |
20 | # include BOOST_ABI_PREFIX | |
21 | #endif | |
22 | ||
23 | #ifdef _MSC_VER | |
24 | # pragma warning(push) | |
25 | # pragma warning(disable:4251) | |
26 | #endif | |
27 | ||
28 | namespace boost { | |
29 | namespace fibers { | |
30 | ||
31 | class condition_variable; | |
32 | ||
33 | class BOOST_FIBERS_DECL mutex { | |
34 | private: | |
35 | friend class condition_variable; | |
36 | ||
7c673cae | 37 | detail::spinlock wait_queue_splk_{}; |
20effc67 | 38 | wait_queue wait_queue_{}; |
b32b8144 | 39 | context * owner_{ nullptr }; |
7c673cae FG |
40 | |
41 | public: | |
42 | mutex() = default; | |
43 | ||
44 | ~mutex() { | |
45 | BOOST_ASSERT( nullptr == owner_); | |
46 | BOOST_ASSERT( wait_queue_.empty() ); | |
47 | } | |
48 | ||
49 | mutex( mutex const&) = delete; | |
50 | mutex & operator=( mutex const&) = delete; | |
51 | ||
52 | void lock(); | |
53 | ||
54 | bool try_lock(); | |
55 | ||
56 | void unlock(); | |
57 | }; | |
58 | ||
59 | }} | |
60 | ||
61 | #ifdef _MSC_VER | |
62 | # pragma warning(pop) | |
63 | #endif | |
64 | ||
65 | #ifdef BOOST_HAS_ABI_HEADERS | |
66 | # include BOOST_ABI_SUFFIX | |
67 | #endif | |
68 | ||
69 | #endif // BOOST_FIBERS_MUTEX_H |