14 Basic I/O services [io_context]

14.3 Class io_context::executor_type [io_context.exec]

14.3.3 io_context::executor_type operations [io_context.exec.ops]

bool running_in_this_thread() const noexcept;

Returns: true if the current thread of execution is calling a run function of the associated io_context object. [ Note: That is, the current thread of execution's call chain includes a run function.  — end note ]

io_context& context() const noexcept;

Returns: A reference to the associated io_context object.

void on_work_started() const noexcept;

Effects: Increments the count of outstanding work associated with the io_context.

void on_work_finished() const noexcept;

Effects: Decrements the count of outstanding work associated with the io_context.

template<class Func, class ProtoAllocator> void dispatch(Func&& f, const ProtoAllocator& a) const;

Effects: If running_in_this_thread() is true, calls DECAY_COPY(forward<Func>(f))() (C++ 2014 [thread.decaycopy]). [ Note: If f exits via an exception, the exception propagates to the caller of dispatch().  — end note ] Otherwise, calls post(forward<Func>(f), a).

template<class Func, class ProtoAllocator> void post(Func&& f, const ProtoAllocator& a) const;

Effects: Adds f to the io_context.

template<class Func, class ProtoAllocator> void defer(Func&& f, const ProtoAllocator& a) const;

Effects: Adds f to the io_context.