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