10ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 20ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// detail/reactor_op.hpp 30ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// ~~~~~~~~~~~~~~~~~~~~~ 40ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 50ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) 60ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 70ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// Distributed under the Boost Software License, Version 1.0. (See accompanying 80ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 90ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 100ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 110ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#ifndef ASIO_DETAIL_REACTOR_OP_HPP 120ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#define ASIO_DETAIL_REACTOR_OP_HPP 130ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 140ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 150ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#include "asio/detail/config.hpp" 160ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#include "asio/detail/operation.hpp" 170ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 180ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#include "asio/detail/push_options.hpp" 190ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 200ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffienamespace asio { 210ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffienamespace detail { 220ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 230ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieclass reactor_op 240ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie : public operation 250ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie{ 260ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffiepublic: 270ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie // The error code to be passed to the completion handler. 280ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie asio::error_code ec_; 290ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 300ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie // The number of bytes transferred, to be passed to the completion handler. 310ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie std::size_t bytes_transferred_; 320ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 330ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie // Perform the operation. Returns true if it is finished. 340ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie bool perform() 350ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie { 360ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie return perform_func_(this); 370ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie } 380ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 390ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieprotected: 400ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie typedef bool (*perform_func_type)(reactor_op*); 410ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 420ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie reactor_op(perform_func_type perform_func, func_type complete_func) 430ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie : operation(complete_func), 440ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie bytes_transferred_(0), 450ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie perform_func_(perform_func) 460ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie { 470ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie } 480ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 490ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieprivate: 500ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie perform_func_type perform_func_; 510ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie}; 520ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 530ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie} // namespace detail 540ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie} // namespace asio 550ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 560ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#include "asio/detail/pop_options.hpp" 570ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 580ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#endif // ASIO_DETAIL_REACTOR_OP_HPP 59