]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/include/boost/thread/poly_lockable.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / thread / include / boost / thread / poly_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_LOCKABLE_HPP
12 #define BOOST_THREAD_POLY_LOCKABLE_HPP
13
14 #include <boost/thread/detail/delete.hpp>
15 #include <boost/chrono/chrono.hpp>
16
17 namespace boost
18 {
19
20 //[basic_poly_lockable
21 class basic_poly_lockable
22 {
23 public:
24
25 virtual ~basic_poly_lockable() = 0;
26
27 virtual void lock() = 0;
28 virtual void unlock() = 0;
29
30 };
31 //]
32
33 //[poly_lockable
34 class poly_lockable : public basic_poly_lockable
35 {
36 public:
37
38 virtual ~poly_lockable() = 0;
39 virtual bool try_lock() = 0;
40 };
41 //]
42
43 //[timed_poly_lockable
44 class timed_poly_lockable: public poly_lockable
45 {
46 public:
47 virtual ~timed_poly_lockable()=0;
48
49 virtual bool try_lock_until(chrono::system_clock::time_point const & abs_time)=0;
50 virtual bool try_lock_until(chrono::steady_clock::time_point const & abs_time)=0;
51 template <typename Clock, typename Duration>
52 bool try_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
53 {
54 return try_lock_until(time_point_cast<Clock::time_point>(abs_time));
55 }
56
57 virtual bool try_lock_for(chrono::nanoseconds const & relative_time)=0;
58 template <typename Rep, typename Period>
59 bool try_lock_for(chrono::duration<Rep, Period> const & rel_time)
60 {
61 return try_lock_for(duration_cast<Clock::duration>(rel_time));
62 }
63
64 };
65 //]
66
67 }
68 #endif