Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //
0002 // detail/scheduler_operation.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_SCHEDULER_OPERATION_HPP
0012 #define BOOST_ASIO_DETAIL_SCHEDULER_OPERATION_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/system/error_code.hpp>
0019 #include <boost/asio/detail/handler_tracking.hpp>
0020 #include <boost/asio/detail/op_queue.hpp>
0021 
0022 #include <boost/asio/detail/push_options.hpp>
0023 
0024 namespace boost {
0025 namespace asio {
0026 namespace detail {
0027 
0028 class scheduler;
0029 
0030 // Base class for all operations. A function pointer is used instead of virtual
0031 // functions to avoid the associated overhead.
0032 class scheduler_operation BOOST_ASIO_INHERIT_TRACKED_HANDLER
0033 {
0034 public:
0035   typedef scheduler_operation operation_type;
0036 
0037   void complete(void* owner, const boost::system::error_code& ec,
0038       std::size_t bytes_transferred)
0039   {
0040     func_(owner, this, ec, bytes_transferred);
0041   }
0042 
0043   void destroy()
0044   {
0045     func_(0, this, boost::system::error_code(), 0);
0046   }
0047 
0048 protected:
0049   typedef void (*func_type)(void*,
0050       scheduler_operation*,
0051       const boost::system::error_code&, std::size_t);
0052 
0053   scheduler_operation(func_type func)
0054     : next_(0),
0055       func_(func),
0056       task_result_(0)
0057   {
0058   }
0059 
0060   // Prevents deletion through this type.
0061   ~scheduler_operation()
0062   {
0063   }
0064 
0065 private:
0066   friend class op_queue_access;
0067   scheduler_operation* next_;
0068   func_type func_;
0069 protected:
0070   friend class scheduler;
0071   unsigned int task_result_; // Passed into bytes transferred.
0072 };
0073 
0074 } // namespace detail
0075 } // namespace asio
0076 } // namespace boost
0077 
0078 #include <boost/asio/detail/pop_options.hpp>
0079 
0080 #endif // BOOST_ASIO_DETAIL_SCHEDULER_OPERATION_HPP