feat: Move/copy support in async framework (#1609)

Fixes #1608
This commit is contained in:
Alex Kremer
2024-08-20 13:24:51 +01:00
committed by GitHub
parent fb473f6d28
commit 9a9de501e4
18 changed files with 290 additions and 54 deletions

View File

@@ -40,6 +40,12 @@ struct ExecutionContextTests : public ::testing::Test {
TYPED_TEST_CASE(ExecutionContextTests, ExecutionContextTypes);
TYPED_TEST(ExecutionContextTests, move)
{
auto mineNow = std::move(this->ctx);
EXPECT_TRUE(mineNow.execute([] { return true; }).get().value());
}
TYPED_TEST(ExecutionContextTests, execute)
{
auto res = this->ctx.execute([]() { return 42; });
@@ -161,6 +167,15 @@ TYPED_TEST(ExecutionContextTests, timerUnknownException)
EXPECT_TRUE(std::string{err}.ends_with("unknown"));
}
TYPED_TEST(ExecutionContextTests, strandMove)
{
auto strand = this->ctx.makeStrand();
auto yoink = std::move(strand);
auto res = yoink.execute([] { return 42; });
EXPECT_EQ(res.get().value(), 42);
}
TYPED_TEST(ExecutionContextTests, strand)
{
auto strand = this->ctx.makeStrand();