asio C++ library

PrevUpHomeNext
io_context::strand::dispatch (2 of 2 overloads)

(Deprecated: Use dispatch.) Request the strand to invoke the given handler.

template<
    typename LegacyCompletionHandler>
DEDUCED dispatch(
    LegacyCompletionHandler && handler);

This function is used to ask the strand to execute the given handler.

The strand object guarantees that handlers posted or dispatched through the strand will not be executed concurrently. The handler may be executed inside this function if the guarantee can be met. If this function is called from within a handler that was posted or dispatched through the same strand, then the new handler will be executed immediately.

The strand's guarantee is in addition to the guarantee provided by the underlying io_context. The io_context guarantees that the handler will only be called in a thread in which the io_context's run member function is currently being invoked.

Parameters

handler

The handler to be called. The strand will make a copy of the handler object as required. The function signature of the handler must be:

void handler();

PrevUpHomeNext