null_event.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // detail/null_event.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 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. // If there's a waiter, unlock the mutex and signal it.
  49. template <typename Lock>
  50. bool maybe_unlock_and_signal_one(Lock&)
  51. {
  52. return false;
  53. }
  54. // Reset the event.
  55. template <typename Lock>
  56. void clear(Lock&)
  57. {
  58. }
  59. // Wait for the event to become signalled.
  60. template <typename Lock>
  61. void wait(Lock&)
  62. {
  63. do_wait();
  64. }
  65. // Timed wait for the event to become signalled.
  66. template <typename Lock>
  67. bool wait_for_usec(Lock&, long usec)
  68. {
  69. do_wait_for_usec(usec);
  70. return true;
  71. }
  72. private:
  73. BOOST_ASIO_DECL static void do_wait();
  74. BOOST_ASIO_DECL static void do_wait_for_usec(long usec);
  75. };
  76. } // namespace detail
  77. } // namespace asio
  78. } // namespace boost
  79. #include <boost/asio/detail/pop_options.hpp>
  80. #if defined(BOOST_ASIO_HEADER_ONLY)
  81. # include <boost/asio/detail/impl/null_event.ipp>
  82. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  83. #endif // BOOST_ASIO_DETAIL_NULL_EVENT_HPP