Chris@16: // Chris@16: // detail/win_iocp_operation.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP Chris@16: #define BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_HAS_IOCP) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: Chris@16: class win_iocp_io_service; Chris@16: Chris@16: // Base class for all operations. A function pointer is used instead of virtual Chris@16: // functions to avoid the associated overhead. Chris@16: class win_iocp_operation Chris@16: : public OVERLAPPED Chris@16: BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER Chris@16: { Chris@16: public: Chris@16: void complete(win_iocp_io_service& owner, Chris@16: const boost::system::error_code& ec, Chris@16: std::size_t bytes_transferred) Chris@16: { Chris@16: func_(&owner, this, ec, bytes_transferred); Chris@16: } Chris@16: Chris@16: void destroy() Chris@16: { Chris@16: func_(0, this, boost::system::error_code(), 0); Chris@16: } Chris@16: Chris@16: protected: Chris@16: typedef void (*func_type)( Chris@16: win_iocp_io_service*, win_iocp_operation*, Chris@16: const boost::system::error_code&, std::size_t); Chris@16: Chris@16: win_iocp_operation(func_type func) Chris@16: : next_(0), Chris@16: func_(func) Chris@16: { Chris@16: reset(); Chris@16: } Chris@16: Chris@16: // Prevents deletion through this type. Chris@16: ~win_iocp_operation() Chris@16: { Chris@16: } Chris@16: Chris@16: void reset() Chris@16: { Chris@16: Internal = 0; Chris@16: InternalHigh = 0; Chris@16: Offset = 0; Chris@16: OffsetHigh = 0; Chris@16: hEvent = 0; Chris@16: ready_ = 0; Chris@16: } Chris@16: Chris@16: private: Chris@16: friend class op_queue_access; Chris@16: friend class win_iocp_io_service; Chris@16: win_iocp_operation* next_; Chris@16: func_type func_; Chris@16: long ready_; Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // defined(BOOST_ASIO_HAS_IOCP) Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP