Chris@16
|
1 //
|
Chris@16
|
2 // detail/win_iocp_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_WIN_IOCP_OPERATION_HPP
|
Chris@16
|
12 #define BOOST_ASIO_DETAIL_WIN_IOCP_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/asio/detail/config.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #if defined(BOOST_ASIO_HAS_IOCP)
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/asio/detail/handler_tracking.hpp>
|
Chris@16
|
23 #include <boost/asio/detail/op_queue.hpp>
|
Chris@16
|
24 #include <boost/asio/detail/socket_types.hpp>
|
Chris@16
|
25 #include <boost/system/error_code.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost {
|
Chris@16
|
30 namespace asio {
|
Chris@16
|
31 namespace detail {
|
Chris@16
|
32
|
Chris@16
|
33 class win_iocp_io_service;
|
Chris@16
|
34
|
Chris@16
|
35 // Base class for all operations. A function pointer is used instead of virtual
|
Chris@16
|
36 // functions to avoid the associated overhead.
|
Chris@16
|
37 class win_iocp_operation
|
Chris@16
|
38 : public OVERLAPPED
|
Chris@16
|
39 BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER
|
Chris@16
|
40 {
|
Chris@16
|
41 public:
|
Chris@16
|
42 void complete(win_iocp_io_service& owner,
|
Chris@16
|
43 const boost::system::error_code& ec,
|
Chris@16
|
44 std::size_t bytes_transferred)
|
Chris@16
|
45 {
|
Chris@16
|
46 func_(&owner, this, ec, bytes_transferred);
|
Chris@16
|
47 }
|
Chris@16
|
48
|
Chris@16
|
49 void destroy()
|
Chris@16
|
50 {
|
Chris@16
|
51 func_(0, this, boost::system::error_code(), 0);
|
Chris@16
|
52 }
|
Chris@16
|
53
|
Chris@16
|
54 protected:
|
Chris@16
|
55 typedef void (*func_type)(
|
Chris@16
|
56 win_iocp_io_service*, win_iocp_operation*,
|
Chris@16
|
57 const boost::system::error_code&, std::size_t);
|
Chris@16
|
58
|
Chris@16
|
59 win_iocp_operation(func_type func)
|
Chris@16
|
60 : next_(0),
|
Chris@16
|
61 func_(func)
|
Chris@16
|
62 {
|
Chris@16
|
63 reset();
|
Chris@16
|
64 }
|
Chris@16
|
65
|
Chris@16
|
66 // Prevents deletion through this type.
|
Chris@16
|
67 ~win_iocp_operation()
|
Chris@16
|
68 {
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 void reset()
|
Chris@16
|
72 {
|
Chris@16
|
73 Internal = 0;
|
Chris@16
|
74 InternalHigh = 0;
|
Chris@16
|
75 Offset = 0;
|
Chris@16
|
76 OffsetHigh = 0;
|
Chris@16
|
77 hEvent = 0;
|
Chris@16
|
78 ready_ = 0;
|
Chris@16
|
79 }
|
Chris@16
|
80
|
Chris@16
|
81 private:
|
Chris@16
|
82 friend class op_queue_access;
|
Chris@16
|
83 friend class win_iocp_io_service;
|
Chris@16
|
84 win_iocp_operation* next_;
|
Chris@16
|
85 func_type func_;
|
Chris@16
|
86 long ready_;
|
Chris@16
|
87 };
|
Chris@16
|
88
|
Chris@16
|
89 } // namespace detail
|
Chris@16
|
90 } // namespace asio
|
Chris@16
|
91 } // namespace boost
|
Chris@16
|
92
|
Chris@16
|
93 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
94
|
Chris@16
|
95 #endif // defined(BOOST_ASIO_HAS_IOCP)
|
Chris@16
|
96
|
Chris@16
|
97 #endif // BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP
|