123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- #ifndef BOOST_ASIO_STRAND_HPP
- #define BOOST_ASIO_STRAND_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <boost/asio/async_result.hpp>
- #include <boost/asio/detail/handler_type_requirements.hpp>
- #include <boost/asio/detail/strand_service.hpp>
- #include <boost/asio/detail/wrapped_handler.hpp>
- #include <boost/asio/io_service.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- class io_service::strand
- {
- public:
-
-
- explicit strand(boost::asio::io_service& io_service)
- : service_(boost::asio::use_service<
- boost::asio::detail::strand_service>(io_service))
- {
- service_.construct(impl_);
- }
-
-
- ~strand()
- {
- }
-
-
- boost::asio::io_service& get_io_service()
- {
- return service_.get_io_service();
- }
-
-
- template <typename CompletionHandler>
- BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
- dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
- {
-
-
- BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
- detail::async_result_init<
- CompletionHandler, void ()> init(
- BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
- service_.dispatch(impl_, init.handler);
- return init.result.get();
- }
-
-
-
- template <typename CompletionHandler>
- BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
- post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
- {
-
-
- BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
- detail::async_result_init<
- CompletionHandler, void ()> init(
- BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
- service_.post(impl_, init.handler);
- return init.result.get();
- }
-
-
-
- template <typename Handler>
- #if defined(GENERATING_DOCUMENTATION)
- unspecified
- #else
- detail::wrapped_handler<strand, Handler, detail::is_continuation_if_running>
- #endif
- wrap(Handler handler)
- {
- return detail::wrapped_handler<io_service::strand, Handler,
- detail::is_continuation_if_running>(*this, handler);
- }
-
-
- bool running_in_this_thread() const
- {
- return service_.running_in_this_thread(impl_);
- }
- private:
- boost::asio::detail::strand_service& service_;
- boost::asio::detail::strand_service::implementation_type impl_;
- };
- typedef boost::asio::io_service::strand strand;
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|