MCPcopy Create free account
hub / github.com/Icinga/icinga2 / SpawnSynchronizedCoroutine

Function SpawnSynchronizedCoroutine

test/utils.cpp:73–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73std::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}

Callers 2

BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected