Chris@16: // Chris@16: // detail/impl/select_reactor.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP Chris@16: #define BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_HAS_IOCP) \ Chris@16: || (!defined(BOOST_ASIO_HAS_DEV_POLL) \ Chris@16: && !defined(BOOST_ASIO_HAS_EPOLL) \ Chris@16: && !defined(BOOST_ASIO_HAS_KQUEUE) \ Chris@16: && !defined(BOOST_ASIO_WINDOWS_RUNTIME)) Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: Chris@16: template Chris@16: void select_reactor::add_timer_queue(timer_queue& queue) Chris@16: { Chris@16: do_add_timer_queue(queue); Chris@16: } Chris@16: Chris@16: // Remove a timer queue from the reactor. Chris@16: template Chris@16: void select_reactor::remove_timer_queue(timer_queue& queue) Chris@16: { Chris@16: do_remove_timer_queue(queue); Chris@16: } Chris@16: Chris@16: template Chris@16: void select_reactor::schedule_timer(timer_queue& queue, Chris@16: const typename Time_Traits::time_type& time, Chris@16: typename timer_queue::per_timer_data& timer, wait_op* op) Chris@16: { Chris@16: boost::asio::detail::mutex::scoped_lock lock(mutex_); Chris@16: Chris@16: if (shutdown_) Chris@16: { Chris@16: io_service_.post_immediate_completion(op, false); Chris@16: return; Chris@16: } Chris@16: Chris@16: bool earliest = queue.enqueue_timer(time, timer, op); Chris@16: io_service_.work_started(); Chris@16: if (earliest) Chris@16: interrupter_.interrupt(); Chris@16: } Chris@16: Chris@16: template Chris@16: std::size_t select_reactor::cancel_timer(timer_queue& queue, Chris@16: typename timer_queue::per_timer_data& timer, Chris@16: std::size_t max_cancelled) Chris@16: { Chris@16: boost::asio::detail::mutex::scoped_lock lock(mutex_); Chris@16: op_queue ops; Chris@16: std::size_t n = queue.cancel_timer(timer, ops, max_cancelled); Chris@16: lock.unlock(); Chris@16: io_service_.post_deferred_completions(ops); Chris@16: return n; Chris@16: } Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // defined(BOOST_ASIO_HAS_IOCP) Chris@16: // || (!defined(BOOST_ASIO_HAS_DEV_POLL) Chris@16: // && !defined(BOOST_ASIO_HAS_EPOLL) Chris@16: // && !defined(BOOST_ASIO_HAS_KQUEUE) Chris@16: // && !defined(BOOST_ASIO_WINDOWS_RUNTIME)) Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP