[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLggL7MTLVv2ym_tCCKH9hQtL=GpTwXjDUQzKQX9UdT7SkA@mail.gmail.com>
Date: Tue, 19 Nov 2024 17:28:36 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Tamir Duberstein <tamird@...il.com>
Cc: Boqun Feng <boqun.feng@...il.com>, Danilo Krummrich <dakr@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Maíra Canal <mcanal@...lia.com>,
Asahi Lina <lina@...hilina.net>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v9 2/2] rust: xarray: Add an abstraction for XArray
On Tue, Nov 19, 2024 at 5:24 PM Tamir Duberstein <tamird@...il.com> wrote:
>
> On Mon, Nov 18, 2024 at 5:18 PM Boqun Feng <boqun.feng@...il.com> wrote:
> >
> > On Mon, Nov 18, 2024 at 11:33:36AM -0500, Tamir Duberstein wrote:
> > [...]
> > > +
> > > +/// A lock guard.
> > > +///
> > > +/// The lock is unlocked when the guard goes out of scope.
> > > +#[must_use = "the lock unlocks immediately when the guard is unused"]
> > > +pub struct Guard<'a, T: ForeignOwnable> {
> > > + xa: &'a XArray<T>,
> > > +}
> >
> > `Guard` would be `Send` if `XArray<T>` is `Sync`, however, it's
> > incorrect since `Guard` represents an xa_lock() held, and that's a
> > spin_lock, so cannot be dropped on another thread/context. `Guard`
> > should probably be marked as `!Send`. Or am I missing something subtle
> > here?
>
> I didn't know about this requirement, thanks for calling it out. I
> have added `_not_send: PhantomData<*mut ()>` in v10.
You can use _nts: NotThreadSafe. The type in question has landed in
6.13 and is available in Linus's tree since yesterday.
Alice
Powered by blists - more mailing lists