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