I'm spawning a bunch of tasks that can be killed using an application-defined task identifier. On shutdown, I want to signal every task to self-terminate and then allow the caller to wait until all the tasks have terminated. Earlier I didn't have access to each task's JoinHandle
, so I couldn't use that. After some replumbing I fixed that so I simply iterate over all JoinHandle
's and await
them. Problem solved!
However; assuming I couldn't have done that -- is there some already-existing solution for this? I'm looking for something akin to tokio's Semaphore, but with the ability to .await
until all permits have been dropped.