Async/futures: Shutting down tasks

Say you have a bunch of listener tasks and a few connection tasks running, and at the root of it all is something waiting for some kind of termination event (like SIG{TERM,INT}).

Once the termination condition has been fulfilled, what methods are typically used to cause a clean shutdown of all tasks? (Assuming that some tasks, in particular the listeners, may .await for a long time).

I found stream-cancel, which looks promising -- but I'm wondering what other methods there are in use out in the wild.

Some common methods include a broadcast channel or the abortable utility.

1 Like