PageRenderTime 25ms CodeModel.GetById 12ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/asio/detail/impl/select_reactor.hpp

http://hadesmem.googlecode.com/
C++ Header | 87 lines | 58 code | 16 blank | 13 comment | 6 complexity | 8d7d9997d953b467745fe75d13eae402 MD5 | raw file
 1//
 2// detail/impl/select_reactor.hpp
 3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4//
 5// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 6//
 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)
 9//
10
11#ifndef BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP
12#define BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19
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
25#include <boost/asio/detail/push_options.hpp>
26
27namespace boost {
28namespace asio {
29namespace detail {
30
31template <typename Time_Traits>
32void select_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
33{
34  do_add_timer_queue(queue);
35}
36
37// Remove a timer queue from the reactor.
38template <typename Time_Traits>
39void select_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue)
40{
41  do_remove_timer_queue(queue);
42}
43
44template <typename Time_Traits>
45void select_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
46    const typename Time_Traits::time_type& time,
47    typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op)
48{
49  boost::asio::detail::mutex::scoped_lock lock(mutex_);
50
51  if (shutdown_)
52  {
53    io_service_.post_immediate_completion(op);
54    return;
55  }
56
57  bool earliest = queue.enqueue_timer(time, timer, op);
58  io_service_.work_started();
59  if (earliest)
60    interrupter_.interrupt();
61}
62
63template <typename Time_Traits>
64std::size_t select_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
65    typename timer_queue<Time_Traits>::per_timer_data& timer,
66    std::size_t max_cancelled)
67{
68  boost::asio::detail::mutex::scoped_lock lock(mutex_);
69  op_queue<operation> ops;
70  std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
71  lock.unlock();
72  io_service_.post_deferred_completions(ops);
73  return n;
74}
75
76} // namespace detail
77} // namespace asio
78} // namespace boost
79
80#include <boost/asio/detail/pop_options.hpp>
81
82#endif // defined(BOOST_ASIO_HAS_IOCP)
83       //   || (!defined(BOOST_ASIO_HAS_DEV_POLL)
84       //       && !defined(BOOST_ASIO_HAS_EPOLL)
85       //       && !defined(BOOST_ASIO_HAS_KQUEUE))
86
87#endif // BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP