MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / dispatch

Method dispatch

3rd/asio-1.24.0/include/asio/impl/io_context.hpp:347–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345template <typename Allocator, uintptr_t Bits>
346template <typename Function, typename OtherAllocator>
347void io_context::basic_executor_type<Allocator, Bits>::dispatch(
348 ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const
349{
350 typedef typename decay<Function>::type function_type;
351
352 // Invoke immediately if we are already inside the thread pool.
353 if (context_ptr()->impl_.can_dispatch())
354 {
355 // Make a local, non-const copy of the function.
356 function_type tmp(ASIO_MOVE_CAST(Function)(f));
357
358 detail::fenced_block b(detail::fenced_block::full);
359 asio_handler_invoke_helpers::invoke(tmp, tmp);
360 return;
361 }
362
363 // Allocate and construct an operation to wrap the function.
364 typedef detail::executor_op<function_type,
365 OtherAllocator, detail::operation> op;
366 typename op::ptr p = { detail::addressof(a), op::ptr::allocate(a), 0 };
367 p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(f), a);
368
369 ASIO_HANDLER_CREATION((*context_ptr(), *p.p,
370 "io_context", context_ptr(), 0, "dispatch"));
371
372 context_ptr()->impl_.post_immediate_completion(p.p, false);
373 p.v = p.p = 0;
374}
375
376template <typename Allocator, uintptr_t Bits>
377template <typename Function, typename OtherAllocator>

Callers

nothing calls this directly

Calls 4

context_ptrFunction · 0.85
invokeFunction · 0.85
allocateFunction · 0.50

Tested by

no test coverage detected