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