async: switch to stdexec async_scope
Use the `async_scope` implementation from stdexec instead of the
custom `scope` class here, which greatly reduces our own code and
also aligns better with the C++ STL direction. The major changes are
around exception paths:
- Spawned tasks which end with an exception will now std::terminate,
so any task expected to throw should have an `upon_error` chain.
- Spawned tasks which are stopped will be no longer throw an
`UnexpectedStop` exception, so they should be chained with an
`upon_stopped` if this is important.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I4e0c85712652efa5b296b898dcc2b0026ba4c625
diff --git a/test/async/context.cpp b/test/async/context.cpp
index 7d7f6fa..8cdd93c 100644
--- a/test/async/context.cpp
+++ b/test/async/context.cpp
@@ -48,48 +48,6 @@
}
}
-TEST_F(Context, SpawnThrowingTask)
-{
- ctx->spawn(stdexec::just() |
- stdexec::then([]() { throw std::logic_error("Oops"); }));
-
- EXPECT_THROW(runToStop(), std::logic_error);
- ctx->run();
-}
-
-TEST_F(Context, SpawnThrowingCoroutine)
-{
- struct _
- {
- static auto one() -> sdbusplus::async::task<>
- {
- throw std::logic_error("Oops");
- co_return;
- }
- };
-
- ctx->spawn(_::one());
- EXPECT_THROW(runToStop(), std::logic_error);
- ctx->run();
-};
-
-TEST_F(Context, SpawnManyThrowingTasks)
-{
- static constexpr size_t count = 100;
- for (size_t i = 0; i < count; ++i)
- {
- ctx->spawn(stdexec::just() |
- stdexec::then([]() { throw std::logic_error("Oops"); }));
- }
- spawnStop();
-
- for (size_t i = 0; i < count; ++i)
- {
- EXPECT_THROW(ctx->run(), std::logic_error);
- }
- ctx->run();
-}
-
TEST_F(Context, SpawnDelayedTask)
{
using namespace std::literals;
@@ -153,8 +111,7 @@
ctx->spawn(sdbusplus::async::sleep_for(*ctx, 1ms) |
stdexec::then([&m](...) { m.reset(); }));
- EXPECT_THROW(runToStop(), sdbusplus::exception::UnhandledStop);
- EXPECT_NO_THROW(ctx->run());
+ runToStop();
EXPECT_FALSE(ran);
}
@@ -182,7 +139,6 @@
ctx->spawn(sdbusplus::async::sleep_for(*ctx, 1ms) |
stdexec::then([&]() { m.reset(); }));
- EXPECT_THROW(runToStop(), sdbusplus::exception::UnhandledStop);
- EXPECT_NO_THROW(ctx->run());
+ runToStop();
EXPECT_FALSE(ran);
}