You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unsafefnspawn_inner<T:'a>(&self,future:implFuture<Output = T> + 'a,active:&mutSlab<Waker>,) -> Task<T>{// Remove the task from the set of active tasks when the future finishes.let entry = active.vacant_entry();let index = entry.key();let state = self.state_as_arc();let future = AsyncCallOnDrop::new(future,move || drop(state.active().try_remove(index)));let(runnable, task) = Builder::new().propagate_panic(true).spawn_unchecked(|()| future,self.schedule());
entry.insert(runnable.waker());
runnable.schedule();
task
}
Maybe we should put this logic about reference counting into async-task's Task detaching? For example, detach a Task add a extra reference, and decrease it in extra when the future is completed.
This is a reproduction:
Run test
task_refs
, we can see thedestroyed, ptr: ..
printed, if we useExecutor
, it will not print. I guess this is a bug?The reference count of task is 1, and in the last of
RawTask::run
, it go through this line: https://github.com/smol-rs/async-task/blob/a11c4b22cbcbbdbc4fa0ff62bdbffb430a9d3394/src/raw.rs#L664 , so the task's memory was dealloced.Maybe relevant PR: #112
The text was updated successfully, but these errors were encountered: