Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:43

0001 //
0002 // detail/reactor_op.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_DETAIL_REACTOR_OP_HPP
0012 #define BOOST_ASIO_DETAIL_REACTOR_OP_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/operation.hpp>
0020 
0021 #include <boost/asio/detail/push_options.hpp>
0022 
0023 namespace boost {
0024 namespace asio {
0025 namespace detail {
0026 
0027 class reactor_op
0028   : public operation
0029 {
0030 public:
0031   // The error code to be passed to the completion handler.
0032   boost::system::error_code ec_;
0033 
0034   // The operation key used for targeted cancellation.
0035   void* cancellation_key_;
0036 
0037   // The number of bytes transferred, to be passed to the completion handler.
0038   std::size_t bytes_transferred_;
0039 
0040   // Status returned by perform function. May be used to decide whether it is
0041   // worth performing more operations on the descriptor immediately.
0042   enum status { not_done, done, done_and_exhausted };
0043 
0044   // Perform the operation. Returns true if it is finished.
0045   status perform()
0046   {
0047     return perform_func_(this);
0048   }
0049 
0050 protected:
0051   typedef status (*perform_func_type)(reactor_op*);
0052 
0053   reactor_op(const boost::system::error_code& success_ec,
0054       perform_func_type perform_func, func_type complete_func)
0055     : operation(complete_func),
0056       ec_(success_ec),
0057       cancellation_key_(0),
0058       bytes_transferred_(0),
0059       perform_func_(perform_func)
0060   {
0061   }
0062 
0063 private:
0064   perform_func_type perform_func_;
0065 };
0066 
0067 } // namespace detail
0068 } // namespace asio
0069 } // namespace boost
0070 
0071 #include <boost/asio/detail/pop_options.hpp>
0072 
0073 #endif // BOOST_ASIO_DETAIL_REACTOR_OP_HPP