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