#Run two async tasks in parallel, abort when either finishes

6 messages · Page 1 of 1 (latest)

ornate mason
#

I have two TryStream values that I want to pipe into two sinks for as long as there aren't any errors. In parallel, but as soon as either of them fails, the other should stop too. How do I do that?
This should be robust to panicking: if it is indeed two tasks, a panic in one task should stop the other. This means having a shared flag is not an option.

violet hill
#

then iterate over them fallibly

ornate mason
#

Problem is, they're not homogenous

#

I guess I could wrap them in Either

#

I ended up turning each stream into a Future<()> and driving the two futures in parallel with select!