这是indexloc提供的服务,不要输入任何密码
Skip to content

Should wait_cell::Wait impl Drop? #530

@jamesmunns

Description

@jamesmunns

Currently, WaitCell's Wait future doesn't automatically deregister if the future is dropped before the waiting completes (e.g. in cancellation case).

This could lead to the Waker being held longer than it needs to be, potentially outliving the task itself.

I think this is fine, soundness wise, since an executor needs to unsafely guarantee that a TaskRef lives "long enough", e.g. with an Arc on a heap (that the Waker would hold), or 'static in no-std use cases.

wait_queue::Wait does deregister on drop, using PinnedDrop:

#[pinned_drop]
impl<Lock: ScopedRawMutex> PinnedDrop for Wait<'_, Lock> {
fn drop(mut self: Pin<&mut Self>) {
let this = self.project();
this.waiter.release(this.queue);
}
}
, so we should probably do that for consistency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions