Chris@16
|
1 //
|
Chris@16
|
2 // detail/task_io_service_operation.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
|
Chris@16
|
12 #define BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/system/error_code.hpp>
|
Chris@16
|
19 #include <boost/asio/detail/handler_tracking.hpp>
|
Chris@16
|
20 #include <boost/asio/detail/op_queue.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 namespace boost {
|
Chris@16
|
25 namespace asio {
|
Chris@16
|
26 namespace detail {
|
Chris@16
|
27
|
Chris@16
|
28 class task_io_service;
|
Chris@16
|
29
|
Chris@16
|
30 // Base class for all operations. A function pointer is used instead of virtual
|
Chris@16
|
31 // functions to avoid the associated overhead.
|
Chris@16
|
32 class task_io_service_operation BOOST_ASIO_INHERIT_TRACKED_HANDLER
|
Chris@16
|
33 {
|
Chris@16
|
34 public:
|
Chris@16
|
35 void complete(task_io_service& owner,
|
Chris@16
|
36 const boost::system::error_code& ec, std::size_t bytes_transferred)
|
Chris@16
|
37 {
|
Chris@16
|
38 func_(&owner, this, ec, bytes_transferred);
|
Chris@16
|
39 }
|
Chris@16
|
40
|
Chris@16
|
41 void destroy()
|
Chris@16
|
42 {
|
Chris@16
|
43 func_(0, this, boost::system::error_code(), 0);
|
Chris@16
|
44 }
|
Chris@16
|
45
|
Chris@16
|
46 protected:
|
Chris@16
|
47 typedef void (*func_type)(task_io_service*,
|
Chris@16
|
48 task_io_service_operation*,
|
Chris@16
|
49 const boost::system::error_code&, std::size_t);
|
Chris@16
|
50
|
Chris@16
|
51 task_io_service_operation(func_type func)
|
Chris@16
|
52 : next_(0),
|
Chris@16
|
53 func_(func),
|
Chris@16
|
54 task_result_(0)
|
Chris@16
|
55 {
|
Chris@16
|
56 }
|
Chris@16
|
57
|
Chris@16
|
58 // Prevents deletion through this type.
|
Chris@16
|
59 ~task_io_service_operation()
|
Chris@16
|
60 {
|
Chris@16
|
61 }
|
Chris@16
|
62
|
Chris@16
|
63 private:
|
Chris@16
|
64 friend class op_queue_access;
|
Chris@16
|
65 task_io_service_operation* next_;
|
Chris@16
|
66 func_type func_;
|
Chris@16
|
67 protected:
|
Chris@16
|
68 friend class task_io_service;
|
Chris@16
|
69 unsigned int task_result_; // Passed into bytes transferred.
|
Chris@16
|
70 };
|
Chris@16
|
71
|
Chris@16
|
72 } // namespace detail
|
Chris@16
|
73 } // namespace asio
|
Chris@16
|
74 } // namespace boost
|
Chris@16
|
75
|
Chris@16
|
76 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
77
|
Chris@16
|
78 #endif // BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
|