]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/thread/poly_shared_lockable.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / thread / poly_shared_lockable.hpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/thread for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10
11 #ifndef BOOST_THREAD_POLY_SHARED_LOCKABLE_HPP
12 #define BOOST_THREAD_POLY_SHARED_LOCKABLE_HPP
13
14 #include <boost/thread/poly_lockable.hpp>
15 #include <boost/chrono/chrono.hpp>
16
17 namespace boost
18 {
19
20
21 //[shared_poly_lockable
22 class shared_poly_lockable: public timed_poly_lockable
23 {
24 public:
25 virtual ~shared_poly_lockable() = 0;
26
27 virtual void lock_shared() = 0;
28 virtual bool try_lock_shared() = 0;
29 virtual void unlock_shared() = 0;
30
31 virtual bool try_lock_shared_until(chrono::system_clock::time_point const & abs_time)=0;
32 virtual bool try_lock_shared_until(chrono::steady_clock::time_point const & abs_time)=0;
33 template <typename Clock, typename Duration>
34 bool try_lock_shared_until(chrono::time_point<Clock, Duration> const & abs_time)
35 {
36 return try_lock_shared_until(time_point_cast<Clock::time_point>(abs_time));
37 }
38
39 virtual bool try_lock_shared_for(chrono::nanoseconds const & relative_time)=0;
40 template <typename Rep, typename Period>
41 bool try_lock_shared_for(chrono::duration<Rep, Period> const & rel_time)
42 {
43 return try_lock_shared_for(duration_cast<Clock::duration>(rel_time));
44 }
45
46 };
47
48 //]
49
50 //[upgrade_poly_lockable
51 class upgrade_poly_lockable: public shared_poly_lockable
52 {
53 public:
54 virtual ~upgrade_poly_lockable() = 0;
55
56 virtual void lock_upgrade() = 0;
57 virtual bool try_lock_upgrade() = 0;
58 virtual void unlock_upgrade() = 0;
59
60 virtual bool try_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0;
61 virtual bool try_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)=0;
62 template <typename Clock, typename Duration>
63 bool try_lock_upgrade_until(chrono::time_point<Clock, Duration> const & abs_time)
64 {
65 return try_lock_upgrade_until(time_point_cast<Clock::time_point>(abs_time));
66 }
67
68 virtual bool try_lock_upgrade_for(chrono::nanoseconds const & relative_time)=0;
69 template <typename Rep, typename Period>
70 bool try_lock_upgrade_for(chrono::duration<Rep, Period> const & rel_time)
71 {
72 return try_lock_upgrade_for(duration_cast<Clock::duration>(rel_time));
73 }
74
75 virtual bool try_unlock_shared_and_lock() = 0;
76
77 virtual bool try_unlock_shared_and_lock_until(chrono::system_clock::time_point const & abs_time)=0;
78 virtual bool try_unlock_shared_and_lock_until(chrono::steady_clock::time_point const & abs_time)=0;
79 template <typename Clock, typename Duration>
80 bool try_unlock_shared_and_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
81 {
82 return try_unlock_shared_and_lock_until(time_point_cast<Clock::time_point>(abs_time));
83 }
84
85 virtual bool try_unlock_shared_and_lock_for(chrono::nanoseconds const & relative_time)=0;
86 template <typename Rep, typename Period>
87 bool try_unlock_shared_and_lock_for(chrono::duration<Rep, Period> const & rel_time)
88 {
89 return try_unlock_shared_and_lock_for(duration_cast<Clock::duration>(rel_time));
90 }
91
92 virtual void unlock_and_lock_shared() = 0;
93 virtual bool try_unlock_shared_and_lock_upgrade() = 0;
94
95 virtual bool try_unlock_shared_and_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0;
96 virtual bool try_unlock_shared_and_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)=0;
97 template <typename Clock, typename Duration>
98 bool try_unlock_shared_and_lock_upgrade_until(chrono::time_point<Clock, Duration> const & abs_time)
99 {
100 return try_unlock_shared_and_lock_upgrade_until(time_point_cast<Clock::time_point>(abs_time));
101 }
102
103 virtual bool try_unlock_shared_and_lock_upgrade_for(chrono::nanoseconds const & relative_time)=0;
104 template <typename Rep, typename Period>
105 bool try_unlock_shared_and_lock_upgrade_for(chrono::duration<Rep, Period> const & rel_time)
106 {
107 return try_unlock_shared_and_lock_upgrade_for(duration_cast<Clock::duration>(rel_time));
108 }
109
110 virtual void unlock_and_lock_upgrade() = 0;
111 virtual void unlock_upgrade_and_lock() = 0;
112 virtual bool try_unlock_upgrade_and_lock() = 0;
113
114 virtual bool try_unlock_upgrade_and_lock_until(chrono::system_clock::time_point const & abs_time)=0;
115 virtual bool try_unlock_upgrade_and_lock_until(chrono::steady_clock::time_point const & abs_time)=0;
116 template <typename Clock, typename Duration>
117 bool try_unlock_upgrade_and_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
118 {
119 return try_unlock_upgrade_and_lock_until(time_point_cast<Clock::time_point>(abs_time));
120 }
121
122 virtual bool try_unlock_upgrade_and_lock_for(chrono::nanoseconds const & relative_time)=0;
123 template <typename Rep, typename Period>
124 bool try_unlock_upgrade_and_lock_for(chrono::duration<Rep, Period> const & rel_time)
125 {
126 return try_unlock_upgrade_and_lock_for(duration_cast<Clock::duration>(rel_time));
127 }
128
129 virtual void unlock_upgrade_and_lock_shared() = 0;
130
131 };
132 //]
133
134 }
135 #endif