[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9Fj5nROnMkj8Oau@mango>
Date: Wed, 12 Mar 2025 10:37:29 +0000
From: Oliver Mangold <oliver.mangold@...me>
To: Boqun Feng <boqun.feng@...il.com>
Cc: 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>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Asahi Lina <lina@...hilina.net>, rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 4/4] rust: adding OwnableRefCounted and SimpleOwnableRefCounted
On 250310 1047, Boqun Feng wrote:
> On Mon, Mar 10, 2025 at 10:57:47AM +0000, Oliver Mangold wrote:
> > +pub unsafe trait SimpleOwnableRefCounted {
>
> Can you make this trait as a sub-trait of RefCounted:
>
> pub unsafe trait SimpleOwnableRefCounted: RefCounted {
> fn is_unique(&self) -> bool;
> }
>
> ?
>
Good idea. Simplifies things. Will do that.
> > + /// Checks if exactly one [`ARef`] to the object exists. In case the object is [`Sync`], the
> > + /// check needs to be race-free.
> > + fn is_unique(&self) -> bool;
> > +
> > + /// Increments the reference count on the object.
> > + fn inc_ref(&self);
> > +
> > + /// Decrements the reference count on the object when the [`SimpleOwnableRefCounted`] is
>
> Should be:
>
> "... when ARef<SimpleOwnableRefCounted> or
> Owned<SimpleOwnableRefCounted> is dropped"
>
> ?
>
> > + /// dropped.
> > + ///
> > + /// Frees the object when the count reaches zero.
>
> It may not end up freeing the object, because ARef<..> only tracks the
> Rust side of refcounting, we should avoid mentioning "refcount reaching
> to zero" here.
>
This docu will vanish together with the functions, of course, after the change
above. One might note, though, that the last comment was a copy-paste from
AlwaysRefCounted (now RefCounted) where it still exists identically.
Best regards,
Oliver
Powered by blists - more mailing lists