11 #ifndef ASIO_IO_CONTEXT_STRAND_HPP 12 #define ASIO_IO_CONTEXT_STRAND_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 20 #if !defined(ASIO_NO_EXTENSIONS) \ 21 && !defined(ASIO_NO_TS_EXECUTORS) 23 #include "asio/async_result.hpp" 24 #include "asio/detail/handler_type_requirements.hpp" 25 #include "asio/detail/strand_service.hpp" 26 #include "asio/detail/wrapped_handler.hpp" 27 #include "asio/io_context.hpp" 29 #include "asio/detail/push_options.hpp" 103 service_.construct(impl_);
156 template <
typename Function,
typename Allocator>
157 void dispatch(ASIO_MOVE_ARG(Function) f,
const Allocator& a)
const 159 typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
160 service_.dispatch(impl_, tmp);
164 #if !defined(ASIO_NO_DEPRECATED) 185 template <
typename LegacyCompletionHandler>
187 dispatch(ASIO_MOVE_ARG(LegacyCompletionHandler) handler)
189 return async_initiate<LegacyCompletionHandler, void ()>(
190 initiate_dispatch(), handler,
this);
192 #endif // !defined(ASIO_NO_DEPRECATED) 207 template <
typename Function,
typename Allocator>
208 void post(ASIO_MOVE_ARG(Function) f,
const Allocator& a)
const 210 typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
211 service_.post(impl_, tmp);
215 #if !defined(ASIO_NO_DEPRECATED) 232 template <
typename LegacyCompletionHandler>
234 post(ASIO_MOVE_ARG(LegacyCompletionHandler) handler)
236 return async_initiate<LegacyCompletionHandler, void ()>(
237 initiate_post(), handler,
this);
239 #endif // !defined(ASIO_NO_DEPRECATED) 254 template <
typename Function,
typename Allocator>
255 void defer(ASIO_MOVE_ARG(Function) f,
const Allocator& a)
const 257 typename decay<Function>::type tmp(ASIO_MOVE_CAST(Function)(f));
258 service_.post(impl_, tmp);
262 #if !defined(ASIO_NO_DEPRECATED) 284 template <
typename Handler>
285 #if defined(GENERATING_DOCUMENTATION) 295 #endif // !defined(ASIO_NO_DEPRECATED) 305 return service_.running_in_this_thread(impl_);
315 return a.impl_ == b.impl_;
325 return a.impl_ != b.impl_;
329 #if !defined(ASIO_NO_DEPRECATED) 330 struct initiate_dispatch
332 template <
typename LegacyCompletionHandler>
333 void operator()(ASIO_MOVE_ARG(LegacyCompletionHandler) handler,
339 ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
340 LegacyCompletionHandler, handler) type_check;
343 self->service_.dispatch(self->impl_, handler2.value);
349 template <
typename LegacyCompletionHandler>
350 void operator()(ASIO_MOVE_ARG(LegacyCompletionHandler) handler,
356 ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
357 LegacyCompletionHandler, handler) type_check;
360 self->service_.post(self->impl_, handler2.value);
363 #endif // !defined(ASIO_NO_DEPRECATED) 371 #include "asio/detail/pop_options.hpp" 373 #endif // !defined(ASIO_NO_EXTENSIONS) 376 #endif // ASIO_IO_CONTEXT_STRAND_HPP void on_work_started() const ASIO_NOEXCEPT
Inform the strand that it has some outstanding work to do.
Definition: io_context_strand.hpp:127
Definition: strand_service.hpp:44
strand(asio::io_context &io_context)
Constructor.
Definition: io_context_strand.hpp:99
void on_work_finished() const ASIO_NOEXCEPT
Inform the strand that some work is no longer outstanding.
Definition: io_context_strand.hpp:136
friend bool operator==(const strand &a, const strand &b) ASIO_NOEXCEPT
Compare two strands for equality.
Definition: io_context_strand.hpp:313
friend bool operator!=(const strand &a, const strand &b) ASIO_NOEXCEPT
Compare two strands for inequality.
Definition: io_context_strand.hpp:323
Provides serialised handler execution.
Definition: io_context_strand.hpp:89
ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler, void(asio::error_code, typename Protocol::endpoint)) async_connect(basic_socket< Protocol
Asynchronously establishes a socket connection by trying each endpoint in a sequence.
Provides core I/O functionality.
Definition: io_context.hpp:211
asio::io_context & context() const ASIO_NOEXCEPT
Obtain the underlying execution context.
Definition: io_context_strand.hpp:118
bool running_in_this_thread() const ASIO_NOEXCEPT
Determine whether the strand is running in the current thread.
Definition: io_context_strand.hpp:303
void post(ASIO_MOVE_ARG(Function) f, const Allocator &a) const
Request the strand to invoke the given function object.
Definition: io_context_strand.hpp:208
detail::wrapped_handler< strand, Handler, detail::is_continuation_if_running > wrap(Handler handler)
(Deprecated: Use asio::bind_executor().) Create a new handler that automatically dispatches the wrapp...
Definition: io_context_strand.hpp:290
Definition: non_const_lvalue.hpp:27
Definition: strand_service.hpp:31
void defer(ASIO_MOVE_ARG(Function) f, const Allocator &a) const
Request the strand to invoke the given function object.
Definition: io_context_strand.hpp:255
asio::io_context & get_io_context()
Get the io_context object that owns the service.
Definition: io_context.hpp:431
executor_type get_executor() ASIO_NOEXCEPT
Obtains the executor associated with the io_context.
Definition: io_context.hpp:54
void on_work_finished() const ASIO_NOEXCEPT
Inform the io_context that some work is no longer outstanding.
Definition: io_context.hpp:330
void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator &a) const
Request the strand to invoke the given function object.
Definition: io_context_strand.hpp:157
~strand()
Destructor.
Definition: io_context_strand.hpp:113
Definition: wrapped_handler.hpp:48
Definition: wrapped_handler.hpp:37
Definition: any_io_executor.hpp:28
friend Service & use_service(io_context &ioc)
Definition: io_context.hpp:35
void on_work_started() const ASIO_NOEXCEPT
Inform the io_context that it has some outstanding work to do.
Definition: io_context.hpp:323