| 464 | } |
| 465 | |
| 466 | class thread |
| 467 | { |
| 468 | asio_impl::io_context ctx_; |
| 469 | asio_impl::executor_work_guard<asio_impl::io_context::executor_type> g_; |
| 470 | std::thread t_; |
| 471 | public: |
| 472 | thread() |
| 473 | : g_(ctx_.get_executor()) |
| 474 | , t_( |
| 475 | [&]() noexcept |
| 476 | { |
| 477 | STDEXEC_TRY |
| 478 | { |
| 479 | ctx_.run(); |
| 480 | } |
| 481 | STDEXEC_CATCH_ALL |
| 482 | { |
| 483 | FAIL("Exception thrown in background thread"); |
| 484 | } |
| 485 | }) |
| 486 | {} |
| 487 | |
| 488 | ~thread() noexcept |
| 489 | { |
| 490 | g_.reset(); |
| 491 | if (t_.joinable()) |
| 492 | { |
| 493 | t_.join(); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | void join() noexcept |
| 498 | { |
| 499 | g_.reset(); |
| 500 | t_.join(); |
| 501 | } |
| 502 | |
| 503 | asio_impl::io_context& context() noexcept |
| 504 | { |
| 505 | return ctx_; |
| 506 | } |
| 507 | }; |
| 508 | |
| 509 | template <typename CompletionHandler> |
| 510 | struct ping_pong |
no outgoing calls