| 272 | template <typename Allocator, uintptr_t Bits> |
| 273 | template <typename Function> |
| 274 | void io_context::basic_executor_type<Allocator, Bits>::execute( |
| 275 | ASIO_MOVE_ARG(Function) f) const |
| 276 | { |
| 277 | typedef typename decay<Function>::type function_type; |
| 278 | |
| 279 | // Invoke immediately if the blocking.possibly property is enabled and we are |
| 280 | // already inside the thread pool. |
| 281 | if ((bits() & blocking_never) == 0 && context_ptr()->impl_.can_dispatch()) |
| 282 | { |
| 283 | // Make a local, non-const copy of the function. |
| 284 | function_type tmp(ASIO_MOVE_CAST(Function)(f)); |
| 285 | |
| 286 | #if defined(ASIO_HAS_STD_EXCEPTION_PTR) \ |
| 287 | && !defined(ASIO_NO_EXCEPTIONS) |
| 288 | try |
| 289 | { |
| 290 | #endif // defined(ASIO_HAS_STD_EXCEPTION_PTR) |
| 291 | // && !defined(ASIO_NO_EXCEPTIONS) |
| 292 | detail::fenced_block b(detail::fenced_block::full); |
| 293 | asio_handler_invoke_helpers::invoke(tmp, tmp); |
| 294 | return; |
| 295 | #if defined(ASIO_HAS_STD_EXCEPTION_PTR) \ |
| 296 | && !defined(ASIO_NO_EXCEPTIONS) |
| 297 | } |
| 298 | catch (...) |
| 299 | { |
| 300 | context_ptr()->impl_.capture_current_exception(); |
| 301 | return; |
| 302 | } |
| 303 | #endif // defined(ASIO_HAS_STD_EXCEPTION_PTR) |
| 304 | // && !defined(ASIO_NO_EXCEPTIONS) |
| 305 | } |
| 306 | |
| 307 | // Allocate and construct an operation to wrap the function. |
| 308 | typedef detail::executor_op<function_type, Allocator, detail::operation> op; |
| 309 | typename op::ptr p = { |
| 310 | detail::addressof(static_cast<const Allocator&>(*this)), |
| 311 | op::ptr::allocate(static_cast<const Allocator&>(*this)), 0 }; |
| 312 | p.p = new (p.v) op(ASIO_MOVE_CAST(Function)(f), |
| 313 | static_cast<const Allocator&>(*this)); |
| 314 | |
| 315 | ASIO_HANDLER_CREATION((*context_ptr(), *p.p, |
| 316 | "io_context", context_ptr(), 0, "execute")); |
| 317 | |
| 318 | context_ptr()->impl_.post_immediate_completion(p.p, |
| 319 | (bits() & relationship_continuation) != 0); |
| 320 | p.v = p.p = 0; |
| 321 | } |
| 322 | |
| 323 | #if !defined(ASIO_NO_TS_EXECUTORS) |
| 324 | template <typename Allocator, uintptr_t Bits> |
no test coverage detected