Make poll_to_despawn a no_op

This commit is contained in:
Dániel Buga 2024-12-17 18:51:22 +01:00
parent 2ca374fc9c
commit 76d8a896bb
No known key found for this signature in database

View File

@ -161,10 +161,8 @@ pub struct TaskStorage<F: Future + 'static> {
future: UninitCell<F>, // Valid if STATE_SPAWNED
}
unsafe fn poll_to_despawn(p: TaskRef) {
// The task's future has already been dropped, we just mark it as `!SPAWNED`.
let this = p.header();
this.state.despawn();
unsafe fn poll_exited(_p: TaskRef) {
// Nothing to do, the task is already !SPAWNED and dequeued.
}
impl<F: Future + 'static> TaskStorage<F> {
@ -221,7 +219,7 @@ impl<F: Future + 'static> TaskStorage<F> {
// We replace the poll_fn with a despawn function, so that the task is cleaned up
// when the executor polls it next.
this.raw.poll_fn.set(Some(poll_to_despawn));
this.raw.poll_fn.set(Some(poll_exited));
// Make sure we despawn last, so that other threads can only spawn the task
// after we're done with it.