]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/fiber/include/boost/fiber/timed_mutex.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / fiber / include / boost / fiber / timed_mutex.hpp
CommitLineData
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_TIMED_MUTEX_H
8#define BOOST_FIBERS_TIMED_MUTEX_H
9
10#include <chrono>
11
12#include <boost/assert.hpp>
13#include <boost/config.hpp>
14
15#include <boost/fiber/context.hpp>
16#include <boost/fiber/detail/config.hpp>
17#include <boost/fiber/detail/convert.hpp>
18#include <boost/fiber/detail/spinlock.hpp>
19
20#ifdef BOOST_HAS_ABI_HEADERS
21# include BOOST_ABI_PREFIX
22#endif
23
24#ifdef _MSC_VER
25# pragma warning(push)
26# pragma warning(disable:4251)
27#endif
28
29namespace boost {
30namespace fibers {
31
32class condition_variable;
33
34class BOOST_FIBERS_DECL timed_mutex {
35private:
36 friend class condition_variable;
37
38 typedef context::wait_queue_t wait_queue_t;
39
40 context * owner_{ nullptr };
41 wait_queue_t wait_queue_{};
42 detail::spinlock wait_queue_splk_{};
43
44 bool try_lock_until_( std::chrono::steady_clock::time_point const& timeout_time) noexcept;
45
46public:
47 timed_mutex() = default;
48
49 ~timed_mutex() {
50 BOOST_ASSERT( nullptr == owner_);
51 BOOST_ASSERT( wait_queue_.empty() );
52 }
53
54 timed_mutex( timed_mutex const&) = delete;
55 timed_mutex & operator=( timed_mutex const&) = delete;
56
57 void lock();
58
59 bool try_lock();
60
61 template< typename Clock, typename Duration >
62 bool try_lock_until( std::chrono::time_point< Clock, Duration > const& timeout_time_) {
63 std::chrono::steady_clock::time_point timeout_time(
64 detail::convert( timeout_time_) );
65 return try_lock_until_( timeout_time);
66 }
67
68 template< typename Rep, typename Period >
69 bool try_lock_for( std::chrono::duration< Rep, Period > const& timeout_duration) {
70 return try_lock_until_( std::chrono::steady_clock::now() + timeout_duration);
71 }
72
73 void unlock();
74};
75
76}}
77
78#ifdef _MSC_VER
79# pragma warning(pop)
80#endif
81
82#ifdef BOOST_HAS_ABI_HEADERS
83# include BOOST_ABI_SUFFIX
84#endif
85
86#endif // BOOST_FIBERS_TIMED_MUTEX_H