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