Re: [PATCH v2 6/6] rust: workqueue: add ScopedWork for non-'static work items

"Danilo Krummrich" <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,dev.linux.lists.driver-core,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Fri Aug 7, 2026 at 6:52 PM CEST, Danilo Krummrich wrote:
> +#[pinned_drop]
> +impl<T: ScopedWorkItem> PinnedDrop for ScopedWork<T> {
> +    #[inline]
> +    fn drop(self: Pin<&mut Self>) {
> +        let inner = self.inner.get();
> +
> +        // SAFETY: `inner` points to a valid `ScopedWorkRef`. After `cancel_work_sync()` returns,
> +        // the work function is guaranteed to not be running.
> +        unsafe { bindings::cancel_work_sync(Work::raw_get(&raw const (*inner).work)) };

	// SAFETY: `inner` is valid and no longer accessed by the work function.
	unsafe { core::ptr::drop_in_place(inner) };

> +    }
> +}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.