null_event.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // detail/null_event.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2021 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. #ifndef BOOST_ASIO_DETAIL_NULL_EVENT_HPP
  11. #define BOOST_ASIO_DETAIL_NULL_EVENT_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/detail/noncopyable.hpp>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace detail {
  21. class null_event
  22. : private noncopyable
  23. {
  24. public:
  25. // Constructor.
  26. null_event()
  27. {
  28. }
  29. // Destructor.
  30. ~null_event()
  31. {
  32. }
  33. // Signal the event. (Retained for backward compatibility.)
  34. template <typename Lock>
  35. void signal(Lock&)
  36. {
  37. }
  38. // Signal all waiters.
  39. template <typename Lock>
  40. void signal_all(Lock&)
  41. {
  42. }
  43. // Unlock the mutex and signal one waiter.
  44. template <typename Lock>
  45. void unlock_and_signal_one(Lock&)
  46. {
  47. }
  48. // Unlock the mutex and signal one waiter who may destroy us.
  49. template <typename Lock>
  50. void unlock_and_signal_one_for_destruction(Lock&)
  51. {
  52. }
  53. // If there's a waiter, unlock the mutex and signal it.
  54. template <typename Lock>
  55. bool maybe_unlock_and_signal_one(Lock&)
  56. {
  57. return false;
  58. }
  59. // Reset the event.
  60. template <typename Lock>
  61. void clear(Lock&)
  62. {
  63. }
  64. // Wait for the event to become signalled.
  65. template <typename Lock>
  66. void wait(Lock&)
  67. {
  68. do_wait();
  69. }
  70. // Timed wait for the event to become signalled.
  71. template <typename Lock>
  72. bool wait_for_usec(Lock&, long usec)
  73. {
  74. do_wait_for_usec(usec);
  75. return true;
  76. }
  77. private:
  78. BOOST_ASIO_DECL static void do_wait();
  79. BOOST_ASIO_DECL static void do_wait_for_usec(long usec);
  80. };
  81. } // namespace detail
  82. } // namespace asio
  83. } // namespace boost
  84. #include <boost/asio/detail/pop_options.hpp>
  85. #if defined(BOOST_ASIO_HEADER_ONLY)
  86. # include <boost/asio/detail/impl/null_event.ipp>
  87. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  88. #endif // BOOST_ASIO_DETAIL_NULL_EVENT_HPP