Clementine
null_event.hpp
1 //
2 // detail/null_event.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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 ASIO_DETAIL_NULL_EVENT_HPP
12 #define 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 "asio/detail/config.hpp"
19 #include "asio/detail/noncopyable.hpp"
20 
21 #include "asio/detail/push_options.hpp"
22 
23 namespace asio {
24 namespace detail {
25 
27  : private noncopyable
28 {
29 public:
30  // Constructor.
31  null_event()
32  {
33  }
34 
35  // Destructor.
36  ~null_event()
37  {
38  }
39 
40  // Signal the event. (Retained for backward compatibility.)
41  template <typename Lock>
42  void signal(Lock&)
43  {
44  }
45 
46  // Signal all waiters.
47  template <typename Lock>
48  void signal_all(Lock&)
49  {
50  }
51 
52  // Unlock the mutex and signal one waiter.
53  template <typename Lock>
54  void unlock_and_signal_one(Lock&)
55  {
56  }
57 
58  // Unlock the mutex and signal one waiter who may destroy us.
59  template <typename Lock>
60  void unlock_and_signal_one_for_destruction(Lock&)
61  {
62  }
63 
64  // If there's a waiter, unlock the mutex and signal it.
65  template <typename Lock>
66  bool maybe_unlock_and_signal_one(Lock&)
67  {
68  return false;
69  }
70 
71  // Reset the event.
72  template <typename Lock>
73  void clear(Lock&)
74  {
75  }
76 
77  // Wait for the event to become signalled.
78  template <typename Lock>
79  void wait(Lock&)
80  {
81  do_wait();
82  }
83 
84  // Timed wait for the event to become signalled.
85  template <typename Lock>
86  bool wait_for_usec(Lock&, long usec)
87  {
88  do_wait_for_usec(usec);
89  return true;
90  }
91 
92 private:
93  ASIO_DECL static void do_wait();
94  ASIO_DECL static void do_wait_for_usec(long usec);
95 };
96 
97 } // namespace detail
98 } // namespace asio
99 
100 #include "asio/detail/pop_options.hpp"
101 
102 #if defined(ASIO_HEADER_ONLY)
103 # include "asio/detail/impl/null_event.ipp"
104 #endif // defined(ASIO_HEADER_ONLY)
105 
106 #endif // ASIO_DETAIL_NULL_EVENT_HPP
Definition: noncopyable.hpp:25
Definition: chrono.h:284
Definition: null_event.hpp:26
Definition: any_io_executor.hpp:28