123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #ifndef ASIO_DETAIL_STRAND_SERVICE_HPP
- #define ASIO_DETAIL_STRAND_SERVICE_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include "asio/detail/config.hpp"
- #include "asio/io_context.hpp"
- #include "asio/detail/mutex.hpp"
- #include "asio/detail/op_queue.hpp"
- #include "asio/detail/operation.hpp"
- #include "asio/detail/scoped_ptr.hpp"
- #include "asio/detail/push_options.hpp"
- namespace asio {
- namespace detail {
- class strand_service
- : public asio::detail::service_base<strand_service>
- {
- private:
-
- struct on_do_complete_exit;
-
- struct on_dispatch_exit;
- public:
-
- class strand_impl
- : public operation
- {
- public:
- strand_impl();
- private:
-
- friend class strand_service;
- friend struct on_do_complete_exit;
- friend struct on_dispatch_exit;
-
- asio::detail::mutex mutex_;
-
-
-
- bool locked_;
-
-
-
- op_queue<operation> waiting_queue_;
-
-
-
- op_queue<operation> ready_queue_;
- };
- typedef strand_impl* implementation_type;
-
- ASIO_DECL explicit strand_service(asio::io_context& io_context);
-
- ASIO_DECL void shutdown();
-
- ASIO_DECL void construct(implementation_type& impl);
-
- template <typename Handler>
- void dispatch(implementation_type& impl, Handler& handler);
-
- template <typename Handler>
- void post(implementation_type& impl, Handler& handler);
-
- ASIO_DECL bool running_in_this_thread(
- const implementation_type& impl) const;
- private:
-
- ASIO_DECL void do_dispatch(implementation_type& impl, operation* op);
-
- ASIO_DECL void do_post(implementation_type& impl,
- operation* op, bool is_continuation);
- ASIO_DECL static void do_complete(void* owner,
- operation* base, const asio::error_code& ec,
- std::size_t bytes_transferred);
-
- io_context& io_context_;
-
- io_context_impl& io_context_impl_;
-
- asio::detail::mutex mutex_;
-
- #if defined(ASIO_STRAND_IMPLEMENTATIONS)
- enum { num_implementations = ASIO_STRAND_IMPLEMENTATIONS };
- #else
- enum { num_implementations = 193 };
- #endif
-
- scoped_ptr<strand_impl> implementations_[num_implementations];
-
-
- std::size_t salt_;
- };
- }
- }
- #include "asio/detail/pop_options.hpp"
- #include "asio/detail/impl/strand_service.hpp"
- #if defined(ASIO_HEADER_ONLY)
- # include "asio/detail/impl/strand_service.ipp"
- #endif
- #endif
|