null_event.hpp 2.0 KB

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