]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // detail/null_event.hpp | |
3 | // ~~~~~~~~~~~~~~~~~~~~~ | |
4 | // | |
f67539c2 | 5 | // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
7c673cae FG |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | // | |
10 | ||
11 | #ifndef BOOST_ASIO_DETAIL_NULL_EVENT_HPP | |
12 | #define BOOST_ASIO_DETAIL_NULL_EVENT_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
7c673cae FG |
19 | #include <boost/asio/detail/noncopyable.hpp> |
20 | ||
21 | #include <boost/asio/detail/push_options.hpp> | |
22 | ||
23 | namespace boost { | |
24 | namespace asio { | |
25 | namespace detail { | |
26 | ||
27 | class null_event | |
28 | : private noncopyable | |
29 | { | |
30 | public: | |
31 | // Constructor. | |
32 | null_event() | |
33 | { | |
34 | } | |
35 | ||
36 | // Destructor. | |
37 | ~null_event() | |
38 | { | |
39 | } | |
40 | ||
41 | // Signal the event. (Retained for backward compatibility.) | |
42 | template <typename Lock> | |
43 | void signal(Lock&) | |
44 | { | |
45 | } | |
46 | ||
47 | // Signal all waiters. | |
48 | template <typename Lock> | |
49 | void signal_all(Lock&) | |
50 | { | |
51 | } | |
52 | ||
53 | // Unlock the mutex and signal one waiter. | |
54 | template <typename Lock> | |
55 | void unlock_and_signal_one(Lock&) | |
56 | { | |
57 | } | |
58 | ||
59 | // If there's a waiter, unlock the mutex and signal it. | |
60 | template <typename Lock> | |
61 | bool maybe_unlock_and_signal_one(Lock&) | |
62 | { | |
63 | return false; | |
64 | } | |
65 | ||
66 | // Reset the event. | |
67 | template <typename Lock> | |
68 | void clear(Lock&) | |
69 | { | |
70 | } | |
71 | ||
72 | // Wait for the event to become signalled. | |
73 | template <typename Lock> | |
74 | void wait(Lock&) | |
75 | { | |
b32b8144 | 76 | do_wait(); |
7c673cae | 77 | } |
b32b8144 FG |
78 | |
79 | // Timed wait for the event to become signalled. | |
80 | template <typename Lock> | |
81 | bool wait_for_usec(Lock&, long usec) | |
82 | { | |
83 | do_wait_for_usec(usec); | |
84 | return true; | |
85 | } | |
86 | ||
87 | private: | |
88 | BOOST_ASIO_DECL static void do_wait(); | |
89 | BOOST_ASIO_DECL static void do_wait_for_usec(long usec); | |
7c673cae FG |
90 | }; |
91 | ||
92 | } // namespace detail | |
93 | } // namespace asio | |
94 | } // namespace boost | |
95 | ||
96 | #include <boost/asio/detail/pop_options.hpp> | |
97 | ||
b32b8144 FG |
98 | #if defined(BOOST_ASIO_HEADER_ONLY) |
99 | # include <boost/asio/detail/impl/null_event.ipp> | |
100 | #endif // defined(BOOST_ASIO_HEADER_ONLY) | |
7c673cae FG |
101 | |
102 | #endif // BOOST_ASIO_DETAIL_NULL_EVENT_HPP |