Chris@16: // Chris@16: // detail/task_io_service_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_TASK_IO_SERVICE_OPERATION_HPP Chris@16: #define BOOST_ASIO_DETAIL_TASK_IO_SERVICE_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: #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 task_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 task_io_service_operation BOOST_ASIO_INHERIT_TRACKED_HANDLER Chris@16: { Chris@16: public: Chris@16: void complete(task_io_service& owner, Chris@16: const boost::system::error_code& ec, 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)(task_io_service*, Chris@16: task_io_service_operation*, Chris@16: const boost::system::error_code&, std::size_t); Chris@16: Chris@16: task_io_service_operation(func_type func) Chris@16: : next_(0), Chris@16: func_(func), Chris@16: task_result_(0) Chris@16: { Chris@16: } Chris@16: Chris@16: // Prevents deletion through this type. Chris@16: ~task_io_service_operation() Chris@16: { Chris@16: } Chris@16: Chris@16: private: Chris@16: friend class op_queue_access; Chris@16: task_io_service_operation* next_; Chris@16: func_type func_; Chris@16: protected: Chris@16: friend class task_io_service; Chris@16: unsigned int task_result_; // Passed into bytes transferred. 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 // BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP