From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD93623C8DE for ; Wed, 12 Mar 2025 10:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741775856; cv=none; b=nEUCfJ8z4GbmGMS6bfs+gRepo7OEqwH5GxNSQcJmpFT89wU+Pk9pBCXBQxyDrtbWDlakJi6vkjlTucLVxLTR8Ve0le4wXdSxNkxPAiigQ59bsmlCQ3PQYxB3HZ80IYxv20Ej927uhD5MoeHg7vvAmvJ/NEFFe3lGASRt/b+p2T0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741775856; c=relaxed/simple; bh=iJ4NlzyYcNM12rMMCIVIyvzby6LWOdymnBY0BkuExDM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tA4BVBTejTLMTPX8M9j5i/Fds8OTZsCv8LI2HtSDr/Uc2bSKmpZOf3ZFyfZKdjxQxh9hoSMALjYXaK2BzB870+D0IhD2Ggf61QG+FewocSLH8WXY7SLEfU5KTvKvuA0r2hhaYlWDiWrCDVGZ25E0bEiUDxJHPkeMqc0KPUzkjTI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=Em0Z9Wb/; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="Em0Z9Wb/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1741775852; x=1742035052; bh=KRHpzm/tg2SHCs5xXakiwO2X7kqF1KvJIrw1VAfxtvE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=Em0Z9Wb/LTthJYVnXSW1JrssH3/A407byAVwcuu2LDuL3yrhjkqLrPtnut10+IPPr U+qxkuZDTxHzXRPMSrcL0+SkGBoPlh/YDQBfX4pEMIVmOrt7SDwEVUhVNQxerLltyy 0C6BEhLSmj4rbZypTT0qT8AHU4eAbQj3GGJip2BvPrkhCFl/8zfv/DPpsxkA5/+kzw BsrWpOAYghnwIRx10c7B8NZd+qClGs4R/67HRztHr6X13stpxmkk7pW38Hk+qlSoMi BWkXz+BQOMWvDcqcRYEr1cG1/4dau24LrEc8qFCRfi7lSm6EG1yQD5E4eczkt/f+im RECL5brSZqawQ== Date: Wed, 12 Mar 2025 10:37:29 +0000 To: Boqun Feng From: Oliver Mangold Cc: Miguel Ojeda , Alex Gaynor , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Asahi Lina , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 4/4] rust: adding OwnableRefCounted and SimpleOwnableRefCounted Message-ID: In-Reply-To: References: <20250310-unique-ref-v7-0-4caddb78aa05@pm.me> <20250310-unique-ref-v7-4-4caddb78aa05@pm.me> Feedback-ID: 31808448:user:proton X-Pm-Message-ID: 8d49b651f9b136c85ccb3250c43af42e28a547bc Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 250310 1047, Boqun Feng wrote: > On Mon, Mar 10, 2025 at 10:57:47AM +0000, Oliver Mangold wrote: > > +pub unsafe trait SimpleOwnableRefCounted { >=20 > Can you make this trait as a sub-trait of RefCounted: >=20 > =09pub unsafe trait SimpleOwnableRefCounted: RefCounted { > =09 fn is_unique(&self) -> bool; > =09} >=20 > ? >=20 Good idea. Simplifies things. Will do that. > > + /// Checks if exactly one [`ARef`] to the object exists. In case t= he 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 [`Simple= OwnableRefCounted`] is >=20 > Should be: >=20 > "... when ARef or > Owned is dropped" >=20 > ? >=20 > > + /// dropped. > > + /// > > + /// Frees the object when the count reaches zero. >=20 > 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. >=20 This docu will vanish together with the functions, of course, after the cha= nge 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