• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // detail/reactor_op.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_REACTOR_OP_HPP
12 #define ASIO_DETAIL_REACTOR_OP_HPP
13 
14 
15 #include "asio/detail/config.hpp"
16 #include "asio/detail/operation.hpp"
17 
18 #include "asio/detail/push_options.hpp"
19 
20 namespace asio {
21 namespace detail {
22 
23 class reactor_op
24   : public operation
25 {
26 public:
27   // The error code to be passed to the completion handler.
28   asio::error_code ec_;
29 
30   // The number of bytes transferred, to be passed to the completion handler.
31   std::size_t bytes_transferred_;
32 
33   // Perform the operation. Returns true if it is finished.
perform()34   bool perform()
35   {
36     return perform_func_(this);
37   }
38 
39 protected:
40   typedef bool (*perform_func_type)(reactor_op*);
41 
reactor_op(perform_func_type perform_func,func_type complete_func)42   reactor_op(perform_func_type perform_func, func_type complete_func)
43     : operation(complete_func),
44       bytes_transferred_(0),
45       perform_func_(perform_func)
46   {
47   }
48 
49 private:
50   perform_func_type perform_func_;
51 };
52 
53 } // namespace detail
54 } // namespace asio
55 
56 #include "asio/detail/pop_options.hpp"
57 
58 #endif // ASIO_DETAIL_REACTOR_OP_HPP
59