// // strand_service.hpp // ~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2006 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_STRAND_SERVICE_HPP #define BOOST_ASIO_STRAND_SERVICE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include namespace boost { namespace asio { /// Default service implementation for a strand. class strand_service : public boost::asio::io_service::service { private: // The type of the platform-specific implementation. typedef detail::strand_service service_impl_type; public: /// The implementation type of the strand. #if defined(GENERATING_DOCUMENTATION) typedef implementation_defined implementation_type; #else typedef service_impl_type::implementation_type implementation_type; #endif /// Construct a new timer service for the specified io_service. explicit strand_service(boost::asio::io_service& io_service) : boost::asio::io_service::service(io_service), service_impl_(boost::asio::use_service(io_service)) { } /// Destroy all user-defined handler objects owned by the service. void shutdown_service() { } /// Construct a new timer implementation. void construct(implementation_type& impl) { service_impl_.construct(impl); } /// Destroy a timer implementation. void destroy(implementation_type& impl) { service_impl_.destroy(impl); } /// Request the io_service to invoke the given handler. template void dispatch(implementation_type& impl, Handler handler) { service_impl_.dispatch(impl, handler); } /// Request the io_service to invoke the given handler and return immediately. template void post(implementation_type& impl, Handler handler) { service_impl_.post(impl, handler); } private: // The service that provides the platform-specific implementation. service_impl_type& service_impl_; }; } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_STRAND_SERVICE_HPP