| 71 | } |
| 72 | |
| 73 | std::future<void> SpawnSynchronizedCoroutine(std::function<void(boost::asio::yield_context)> fn) |
| 74 | { |
| 75 | using namespace icinga; |
| 76 | |
| 77 | auto promise = std::make_unique<std::promise<void>>(); |
| 78 | auto future = promise->get_future(); |
| 79 | auto& io = IoEngine::Get().GetIoContext(); |
| 80 | IoEngine::SpawnCoroutine(io, [promise = std::move(promise), fn = std::move(fn)](boost::asio::yield_context yc) { |
| 81 | try { |
| 82 | fn(std::move(yc)); |
| 83 | } catch (const std::exception&) { |
| 84 | promise->set_exception(std::current_exception()); |
| 85 | return; |
| 86 | } |
| 87 | promise->set_value(); |
| 88 | }); |
| 89 | return future; |
| 90 | } |
no outgoing calls
no test coverage detected