Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/exec/async_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ namespace exec {
static void __complete(const __impl* __scope) noexcept {
auto& __active = __scope->__active_;
if (__active.fetch_sub(1, __std::memory_order_acq_rel) == 1) {
usleep(rand() % 1000);
std::unique_lock __guard{__scope->__lock_};
auto __local_waiters = std::move(__scope->__waiters_);
__guard.unlock();
Expand Down
18 changes: 13 additions & 5 deletions test/exec/async_scope/test_spawn_future.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@ namespace {

#if !STDEXEC_STD_NO_EXCEPTIONS()
TEST_CASE("spawn_future with throwing copy", "[async_scope][spawn_future]") {
async_scope scope;
exec::static_thread_pool pool{2};
while(1) {
std::optional<exec::static_thread_pool> pool;
std::shared_ptr<async_scope> scope;

pool.emplace(2);
scope = std::make_shared<async_scope>();

struct throwing_copy {
throwing_copy() = default;
Expand All @@ -154,8 +158,8 @@ namespace {
}
};

ex::sender auto snd = scope.spawn_future(
ex::starts_on(pool.get_scheduler(), exec::just_from([](auto sink) {
ex::sender auto snd = scope->spawn_future(
ex::starts_on(pool->get_scheduler(), exec::just_from([](auto sink) {
return sink(throwing_copy());
})));
STDEXEC_TRY {
Expand All @@ -168,8 +172,12 @@ namespace {
STDEXEC_CATCH_ALL {
FAIL("invalid exception caught");
}
sync_wait(scope.on_empty());
sync_wait(scope->on_empty());

scope.reset();
pool.reset();
}
}
#endif // !STDEXEC_STD_NO_EXCEPTIONS()

TEST_CASE(
Expand Down