Clementine
reactor_op.hpp
1 //
2 // detail/reactor_op.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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_REACTOR_OP_HPP
12 #define ASIO_DETAIL_REACTOR_OP_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 #include "asio/detail/operation.hpp"
20 
21 #include "asio/detail/push_options.hpp"
22 
23 namespace asio {
24 namespace detail {
25 
27  : public operation
28 {
29 public:
30  // The error code to be passed to the completion handler.
31  asio::error_code ec_;
32 
33  // The number of bytes transferred, to be passed to the completion handler.
34  std::size_t bytes_transferred_;
35 
36  // Status returned by perform function. May be used to decide whether it is
37  // worth performing more operations on the descriptor immediately.
38  enum status { not_done, done, done_and_exhausted };
39 
40  // Perform the operation. Returns true if it is finished.
41  status perform()
42  {
43  return perform_func_(this);
44  }
45 
46 protected:
47  typedef status (*perform_func_type)(reactor_op*);
48 
49  reactor_op(const asio::error_code& success_ec,
50  perform_func_type perform_func, func_type complete_func)
51  : operation(complete_func),
52  ec_(success_ec),
53  bytes_transferred_(0),
54  perform_func_(perform_func)
55  {
56  }
57 
58 private:
59  perform_func_type perform_func_;
60 };
61 
62 } // namespace detail
63 } // namespace asio
64 
65 #include "asio/detail/pop_options.hpp"
66 
67 #endif // ASIO_DETAIL_REACTOR_OP_HPP
Definition: chrono.h:284
Class to represent an error code value.
Definition: error_code.hpp:80
Definition: reactor_op.hpp:26
Definition: any_io_executor.hpp:28