2 // detail/impl/select_reactor.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP
12 #define BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(BOOST_ASIO_HAS_IOCP) \
21 || (!defined(BOOST_ASIO_HAS_DEV_POLL) \
22 && !defined(BOOST_ASIO_HAS_EPOLL) \
23 && !defined(BOOST_ASIO_HAS_KQUEUE) \
24 && !defined(BOOST_ASIO_WINDOWS_RUNTIME))
26 #include <boost/asio/detail/push_options.hpp>
32 template <typename Time_Traits>
33 void select_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
35 do_add_timer_queue(queue);
38 // Remove a timer queue from the reactor.
39 template <typename Time_Traits>
40 void select_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue)
42 do_remove_timer_queue(queue);
45 template <typename Time_Traits>
46 void select_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
47 const typename Time_Traits::time_type& time,
48 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
50 boost::asio::detail::mutex::scoped_lock lock(mutex_);
54 io_service_.post_immediate_completion(op, false);
58 bool earliest = queue.enqueue_timer(time, timer, op);
59 io_service_.work_started();
61 interrupter_.interrupt();
64 template <typename Time_Traits>
65 std::size_t select_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
66 typename timer_queue<Time_Traits>::per_timer_data& timer,
67 std::size_t max_cancelled)
69 boost::asio::detail::mutex::scoped_lock lock(mutex_);
70 op_queue<operation> ops;
71 std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
73 io_service_.post_deferred_completions(ops);
81 #include <boost/asio/detail/pop_options.hpp>
83 #endif // defined(BOOST_ASIO_HAS_IOCP)
84 // || (!defined(BOOST_ASIO_HAS_DEV_POLL)
85 // && !defined(BOOST_ASIO_HAS_EPOLL)
86 // && !defined(BOOST_ASIO_HAS_KQUEUE)
87 // && !defined(BOOST_ASIO_WINDOWS_RUNTIME))
89 #endif // BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP