File indexing completed on 2025-01-18 09:28:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_CONDITIONALLY_ENABLED_EVENT_HPP
0012 #define BOOST_ASIO_DETAIL_CONDITIONALLY_ENABLED_EVENT_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/conditionally_enabled_mutex.hpp>
0020 #include <boost/asio/detail/event.hpp>
0021 #include <boost/asio/detail/noncopyable.hpp>
0022 #include <boost/asio/detail/null_event.hpp>
0023 #include <boost/asio/detail/scoped_lock.hpp>
0024
0025 #include <boost/asio/detail/push_options.hpp>
0026
0027 namespace boost {
0028 namespace asio {
0029 namespace detail {
0030
0031
0032 class conditionally_enabled_event
0033 : private noncopyable
0034 {
0035 public:
0036
0037 conditionally_enabled_event()
0038 {
0039 }
0040
0041
0042 ~conditionally_enabled_event()
0043 {
0044 }
0045
0046
0047 void signal(conditionally_enabled_mutex::scoped_lock& lock)
0048 {
0049 if (lock.mutex_.enabled_)
0050 event_.signal(lock);
0051 }
0052
0053
0054 void signal_all(conditionally_enabled_mutex::scoped_lock& lock)
0055 {
0056 if (lock.mutex_.enabled_)
0057 event_.signal_all(lock);
0058 }
0059
0060
0061 void unlock_and_signal_one(
0062 conditionally_enabled_mutex::scoped_lock& lock)
0063 {
0064 if (lock.mutex_.enabled_)
0065 event_.unlock_and_signal_one(lock);
0066 }
0067
0068
0069 void unlock_and_signal_one_for_destruction(
0070 conditionally_enabled_mutex::scoped_lock& lock)
0071 {
0072 if (lock.mutex_.enabled_)
0073 event_.unlock_and_signal_one(lock);
0074 }
0075
0076
0077 bool maybe_unlock_and_signal_one(
0078 conditionally_enabled_mutex::scoped_lock& lock)
0079 {
0080 if (lock.mutex_.enabled_)
0081 return event_.maybe_unlock_and_signal_one(lock);
0082 else
0083 return false;
0084 }
0085
0086
0087 void clear(conditionally_enabled_mutex::scoped_lock& lock)
0088 {
0089 if (lock.mutex_.enabled_)
0090 event_.clear(lock);
0091 }
0092
0093
0094 void wait(conditionally_enabled_mutex::scoped_lock& lock)
0095 {
0096 if (lock.mutex_.enabled_)
0097 event_.wait(lock);
0098 else
0099 null_event().wait(lock);
0100 }
0101
0102
0103 bool wait_for_usec(
0104 conditionally_enabled_mutex::scoped_lock& lock, long usec)
0105 {
0106 if (lock.mutex_.enabled_)
0107 return event_.wait_for_usec(lock, usec);
0108 else
0109 return null_event().wait_for_usec(lock, usec);
0110 }
0111
0112 private:
0113 boost::asio::detail::event event_;
0114 };
0115
0116 }
0117 }
0118 }
0119
0120 #include <boost/asio/detail/pop_options.hpp>
0121
0122 #endif