-
I want to use this feature: When the JoinSet is dropped, all tasks in the JoinSet are immediately aborted. I don't care what tasks return, and I hope those completed task to be dropped automatically from memory. pub struct Client {
pub tasks: JoinSet
}
impl Client {
pub fn start(&self) {
loop {
self.tasks.spawn(async {
// new task
// when completed, remove it from tasks automatically. If I use JoinSet, the memory usage will grow.
})
}
}
}
// when client is dropped, all the tasks are dropped. |
Beta Was this translation helpful? Give feedback.
Answered by
Darksonn
Aug 8, 2023
Replies: 1 comment 9 replies
-
You could remove all completed tasks from the set every time you spawn? |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that it may help to wrap the calls in
tokio::task::unconstrained
.