| 345 | template <typename Allocator, uintptr_t Bits> |
| 346 | template <typename Function, typename OtherAllocator> |
| 347 | void 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 | |
| 376 | template <typename Allocator, uintptr_t Bits> |
| 377 | template <typename Function, typename OtherAllocator> |
nothing calls this directly
no test coverage detected