File indexing completed on 2025-01-18 09:28:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP
0012 #define BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_HAS_IOCP) \
0021 || (!defined(BOOST_ASIO_HAS_DEV_POLL) \
0022 && !defined(BOOST_ASIO_HAS_EPOLL) \
0023 && !defined(BOOST_ASIO_HAS_KQUEUE) \
0024 && !defined(BOOST_ASIO_WINDOWS_RUNTIME))
0025
0026 #if defined(BOOST_ASIO_HAS_IOCP)
0027 # include <boost/asio/detail/win_iocp_io_context.hpp>
0028 #else
0029 # include <boost/asio/detail/scheduler.hpp>
0030 #endif
0031
0032 #include <boost/asio/detail/push_options.hpp>
0033
0034 namespace boost {
0035 namespace asio {
0036 namespace detail {
0037
0038 inline void select_reactor::post_immediate_completion(
0039 operation* op, bool is_continuation) const
0040 {
0041 scheduler_.post_immediate_completion(op, is_continuation);
0042 }
0043
0044 template <typename Time_Traits>
0045 void select_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
0046 {
0047 do_add_timer_queue(queue);
0048 }
0049
0050
0051 template <typename Time_Traits>
0052 void select_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue)
0053 {
0054 do_remove_timer_queue(queue);
0055 }
0056
0057 template <typename Time_Traits>
0058 void select_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
0059 const typename Time_Traits::time_type& time,
0060 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
0061 {
0062 boost::asio::detail::mutex::scoped_lock lock(mutex_);
0063
0064 if (shutdown_)
0065 {
0066 scheduler_.post_immediate_completion(op, false);
0067 return;
0068 }
0069
0070 bool earliest = queue.enqueue_timer(time, timer, op);
0071 scheduler_.work_started();
0072 if (earliest)
0073 interrupter_.interrupt();
0074 }
0075
0076 template <typename Time_Traits>
0077 std::size_t select_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
0078 typename timer_queue<Time_Traits>::per_timer_data& timer,
0079 std::size_t max_cancelled)
0080 {
0081 boost::asio::detail::mutex::scoped_lock lock(mutex_);
0082 op_queue<operation> ops;
0083 std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
0084 lock.unlock();
0085 scheduler_.post_deferred_completions(ops);
0086 return n;
0087 }
0088
0089 template <typename Time_Traits>
0090 void select_reactor::cancel_timer_by_key(timer_queue<Time_Traits>& queue,
0091 typename timer_queue<Time_Traits>::per_timer_data* timer,
0092 void* cancellation_key)
0093 {
0094 mutex::scoped_lock lock(mutex_);
0095 op_queue<operation> ops;
0096 queue.cancel_timer_by_key(timer, ops, cancellation_key);
0097 lock.unlock();
0098 scheduler_.post_deferred_completions(ops);
0099 }
0100
0101 template <typename Time_Traits>
0102 void select_reactor::move_timer(timer_queue<Time_Traits>& queue,
0103 typename timer_queue<Time_Traits>::per_timer_data& target,
0104 typename timer_queue<Time_Traits>::per_timer_data& source)
0105 {
0106 boost::asio::detail::mutex::scoped_lock lock(mutex_);
0107 op_queue<operation> ops;
0108 queue.cancel_timer(target, ops);
0109 queue.move_timer(target, source);
0110 lock.unlock();
0111 scheduler_.post_deferred_completions(ops);
0112 }
0113
0114 }
0115 }
0116 }
0117
0118 #include <boost/asio/detail/pop_options.hpp>
0119
0120 #endif
0121
0122
0123
0124
0125
0126 #endif