facebook / facebook/folly

Future interruption (raise, cancel) doesn't propagate through `collect`

Open
#1,237 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
30.5k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Description

One would expect that interrupting the future resulting from `collect` would interrupt all the source futures, but this doesn't happen.

This prints 0, not 2:

```
int n = 0;

auto [p1, f1] = folly::makePromiseContract();
p1.setInterruptHandler([&](const folly::exception_wrapper& ew) { ++n; });

auto [p2, f2] = folly::makePromiseContract();
p2.setInterruptHandler([&](const folly::exception_wrapper& ew) { ++n; });

auto f = folly::collect(std::move(f1), std::move(f2));

f.cancel();

printf("%d\n", n);
```

Is there a better way to accomplish this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.