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