Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / detail / impl / select_reactor.hpp @ 2486

History | View | Annotate | Download (2.5 kB)

1
//
2
// detail/impl/select_reactor.hpp
3
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
//
5
// Copyright (c) 2003-2015 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
      && !defined(BOOST_ASIO_WINDOWS_RUNTIME))
25

    
26
#include <boost/asio/detail/push_options.hpp>
27

    
28
namespace boost {
29
namespace asio {
30
namespace detail {
31

    
32
template <typename Time_Traits>
33
void select_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
34
{
35
  do_add_timer_queue(queue);
36
}
37

    
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)
41
{
42
  do_remove_timer_queue(queue);
43
}
44

    
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)
49
{
50
  boost::asio::detail::mutex::scoped_lock lock(mutex_);
51

    
52
  if (shutdown_)
53
  {
54
    io_service_.post_immediate_completion(op, false);
55
    return;
56
  }
57

    
58
  bool earliest = queue.enqueue_timer(time, timer, op);
59
  io_service_.work_started();
60
  if (earliest)
61
    interrupter_.interrupt();
62
}
63

    
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)
68
{
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);
72
  lock.unlock();
73
  io_service_.post_deferred_completions(ops);
74
  return n;
75
}
76

    
77
} // namespace detail
78
} // namespace asio
79
} // namespace boost
80

    
81
#include <boost/asio/detail/pop_options.hpp>
82

    
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))
88

    
89
#endif // BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP