Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //
0002 // detail/win_iocp_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_WIN_IOCP_OPERATION_HPP
0012 #define BOOST_ASIO_DETAIL_WIN_IOCP_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/asio/detail/config.hpp>
0019 
0020 #if defined(BOOST_ASIO_HAS_IOCP)
0021 
0022 #include <boost/asio/detail/handler_tracking.hpp>
0023 #include <boost/asio/detail/op_queue.hpp>
0024 #include <boost/asio/detail/socket_types.hpp>
0025 #include <boost/system/error_code.hpp>
0026 
0027 #include <boost/asio/detail/push_options.hpp>
0028 
0029 namespace boost {
0030 namespace asio {
0031 namespace detail {
0032 
0033 class win_iocp_io_context;
0034 
0035 // Base class for all operations. A function pointer is used instead of virtual
0036 // functions to avoid the associated overhead.
0037 class win_iocp_operation
0038   : public OVERLAPPED
0039     BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER
0040 {
0041 public:
0042   typedef win_iocp_operation operation_type;
0043 
0044   void complete(void* owner, const boost::system::error_code& ec,
0045       std::size_t bytes_transferred)
0046   {
0047     func_(owner, this, ec, bytes_transferred);
0048   }
0049 
0050   void destroy()
0051   {
0052     func_(0, this, boost::system::error_code(), 0);
0053   }
0054 
0055   void reset()
0056   {
0057     Internal = 0;
0058     InternalHigh = 0;
0059     Offset = 0;
0060     OffsetHigh = 0;
0061     hEvent = 0;
0062     ready_ = 0;
0063   }
0064 
0065 protected:
0066   typedef void (*func_type)(
0067       void*, win_iocp_operation*,
0068       const boost::system::error_code&, std::size_t);
0069 
0070   win_iocp_operation(func_type func)
0071     : next_(0),
0072       func_(func)
0073   {
0074     reset();
0075   }
0076 
0077   // Prevents deletion through this type.
0078   ~win_iocp_operation()
0079   {
0080   }
0081 
0082 private:
0083   friend class op_queue_access;
0084   friend class win_iocp_io_context;
0085   win_iocp_operation* next_;
0086   func_type func_;
0087   long ready_;
0088 };
0089 
0090 } // namespace detail
0091 } // namespace asio
0092 } // namespace boost
0093 
0094 #include <boost/asio/detail/pop_options.hpp>
0095 
0096 #endif // defined(BOOST_ASIO_HAS_IOCP)
0097 
0098 #endif // BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP