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