Statistics
| Revision:

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

History | View | Annotate | Download (2.3 kB)

1 2486 sjacqu01
//
2 2486 sjacqu01
// detail/impl/task_io_service.hpp
3 2486 sjacqu01
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 2486 sjacqu01
//
5 2486 sjacqu01
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 2486 sjacqu01
//
7 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8 2486 sjacqu01
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 2486 sjacqu01
//
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_HPP
12 2486 sjacqu01
#define BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_HPP
13 2486 sjacqu01
14 2486 sjacqu01
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 2486 sjacqu01
# pragma once
16 2486 sjacqu01
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 2486 sjacqu01
18 2486 sjacqu01
#include <boost/asio/detail/addressof.hpp>
19 2486 sjacqu01
#include <boost/asio/detail/completion_handler.hpp>
20 2486 sjacqu01
#include <boost/asio/detail/fenced_block.hpp>
21 2486 sjacqu01
#include <boost/asio/detail/handler_alloc_helpers.hpp>
22 2486 sjacqu01
#include <boost/asio/detail/handler_cont_helpers.hpp>
23 2486 sjacqu01
#include <boost/asio/detail/handler_invoke_helpers.hpp>
24 2486 sjacqu01
25 2486 sjacqu01
#include <boost/asio/detail/push_options.hpp>
26 2486 sjacqu01
27 2486 sjacqu01
namespace boost {
28 2486 sjacqu01
namespace asio {
29 2486 sjacqu01
namespace detail {
30 2486 sjacqu01
31 2486 sjacqu01
template <typename Handler>
32 2486 sjacqu01
void task_io_service::dispatch(Handler& handler)
33 2486 sjacqu01
{
34 2486 sjacqu01
  if (thread_call_stack::contains(this))
35 2486 sjacqu01
  {
36 2486 sjacqu01
    fenced_block b(fenced_block::full);
37 2486 sjacqu01
    boost_asio_handler_invoke_helpers::invoke(handler, handler);
38 2486 sjacqu01
  }
39 2486 sjacqu01
  else
40 2486 sjacqu01
  {
41 2486 sjacqu01
    // Allocate and construct an operation to wrap the handler.
42 2486 sjacqu01
    typedef completion_handler<Handler> op;
43 2486 sjacqu01
    typename op::ptr p = { boost::asio::detail::addressof(handler),
44 2486 sjacqu01
      boost_asio_handler_alloc_helpers::allocate(
45 2486 sjacqu01
        sizeof(op), handler), 0 };
46 2486 sjacqu01
    p.p = new (p.v) op(handler);
47 2486 sjacqu01
48 2486 sjacqu01
    BOOST_ASIO_HANDLER_CREATION((p.p, "io_service", this, "dispatch"));
49 2486 sjacqu01
50 2486 sjacqu01
    do_dispatch(p.p);
51 2486 sjacqu01
    p.v = p.p = 0;
52 2486 sjacqu01
  }
53 2486 sjacqu01
}
54 2486 sjacqu01
55 2486 sjacqu01
template <typename Handler>
56 2486 sjacqu01
void task_io_service::post(Handler& handler)
57 2486 sjacqu01
{
58 2486 sjacqu01
  bool is_continuation =
59 2486 sjacqu01
    boost_asio_handler_cont_helpers::is_continuation(handler);
60 2486 sjacqu01
61 2486 sjacqu01
  // Allocate and construct an operation to wrap the handler.
62 2486 sjacqu01
  typedef completion_handler<Handler> op;
63 2486 sjacqu01
  typename op::ptr p = { boost::asio::detail::addressof(handler),
64 2486 sjacqu01
    boost_asio_handler_alloc_helpers::allocate(
65 2486 sjacqu01
      sizeof(op), handler), 0 };
66 2486 sjacqu01
  p.p = new (p.v) op(handler);
67 2486 sjacqu01
68 2486 sjacqu01
  BOOST_ASIO_HANDLER_CREATION((p.p, "io_service", this, "post"));
69 2486 sjacqu01
70 2486 sjacqu01
  post_immediate_completion(p.p, is_continuation);
71 2486 sjacqu01
  p.v = p.p = 0;
72 2486 sjacqu01
}
73 2486 sjacqu01
74 2486 sjacqu01
} // namespace detail
75 2486 sjacqu01
} // namespace asio
76 2486 sjacqu01
} // namespace boost
77 2486 sjacqu01
78 2486 sjacqu01
#include <boost/asio/detail/pop_options.hpp>
79 2486 sjacqu01
80 2486 sjacqu01
#endif // BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_HPP