]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // |
b32b8144 FG |
2 | // detail/scheduler_operation.hpp |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
7c673cae | 4 | // |
f67539c2 | 5 | // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
7c673cae FG |
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 | ||
b32b8144 FG |
11 | #ifndef BOOST_ASIO_DETAIL_SCHEDULER_OPERATION_HPP |
12 | #define BOOST_ASIO_DETAIL_SCHEDULER_OPERATION_HPP | |
7c673cae FG |
13 | |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/system/error_code.hpp> | |
19 | #include <boost/asio/detail/handler_tracking.hpp> | |
20 | #include <boost/asio/detail/op_queue.hpp> | |
21 | ||
22 | #include <boost/asio/detail/push_options.hpp> | |
23 | ||
24 | namespace boost { | |
25 | namespace asio { | |
26 | namespace detail { | |
27 | ||
b32b8144 | 28 | class scheduler; |
7c673cae FG |
29 | |
30 | // Base class for all operations. A function pointer is used instead of virtual | |
31 | // functions to avoid the associated overhead. | |
b32b8144 | 32 | class scheduler_operation BOOST_ASIO_INHERIT_TRACKED_HANDLER |
7c673cae FG |
33 | { |
34 | public: | |
b32b8144 FG |
35 | typedef scheduler_operation operation_type; |
36 | ||
37 | void complete(void* owner, const boost::system::error_code& ec, | |
38 | std::size_t bytes_transferred) | |
7c673cae | 39 | { |
b32b8144 | 40 | func_(owner, this, ec, bytes_transferred); |
7c673cae FG |
41 | } |
42 | ||
43 | void destroy() | |
44 | { | |
45 | func_(0, this, boost::system::error_code(), 0); | |
46 | } | |
47 | ||
48 | protected: | |
b32b8144 FG |
49 | typedef void (*func_type)(void*, |
50 | scheduler_operation*, | |
7c673cae FG |
51 | const boost::system::error_code&, std::size_t); |
52 | ||
b32b8144 | 53 | scheduler_operation(func_type func) |
7c673cae FG |
54 | : next_(0), |
55 | func_(func), | |
56 | task_result_(0) | |
57 | { | |
58 | } | |
59 | ||
60 | // Prevents deletion through this type. | |
b32b8144 | 61 | ~scheduler_operation() |
7c673cae FG |
62 | { |
63 | } | |
64 | ||
65 | private: | |
66 | friend class op_queue_access; | |
b32b8144 | 67 | scheduler_operation* next_; |
7c673cae FG |
68 | func_type func_; |
69 | protected: | |
b32b8144 | 70 | friend class scheduler; |
7c673cae FG |
71 | unsigned int task_result_; // Passed into bytes transferred. |
72 | }; | |
73 | ||
74 | } // namespace detail | |
75 | } // namespace asio | |
76 | } // namespace boost | |
77 | ||
78 | #include <boost/asio/detail/pop_options.hpp> | |
79 | ||
b32b8144 | 80 | #endif // BOOST_ASIO_DETAIL_SCHEDULER_OPERATION_HPP |