Re: [PATCH 2/2] rust: arc: remove `ArcBorrow` in favour of `WithRef`
From: Wedson Almeida Filho
Date: Sat Sep 23 2023 - 10:11:49 EST
On Fri, 22 Sept 2023 at 21:13, Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> On Thu, 21 Sep 2023 18:34:40 -0300
> Wedson Almeida Filho <wedsonaf@xxxxxxxxx> wrote:
>
> > From: Wedson Almeida Filho <walmeida@xxxxxxxxxxxxx>
> >
> > With GATs, we don't need a separate type to represent a borrowed object
> > with a refcount, we can just use Rust's regular shared borrowing. In
> > this case, we use `&WithRef<T>` instead of `ArcBorrow<'_, T>`.
> >
> > Co-developed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> > Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> > Signed-off-by: Wedson Almeida Filho <walmeida@xxxxxxxxxxxxx>
>
> Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
>
> The implementation looks good to me, thanks Wedson.
>
> A minor thing that worth considering is to implement `AlwaysRefCounted`
> to `WithRef` and reimplement `Arc` with `ARef<TaskRef<T>>` or add
> conversion functions between them.
>
> It feels natural to have this this impl (because `WithRef` is indeed
> always ref counted), but on the other hand I don't currently foresee
> anyone to currently want to use this API :(
Yes, I like the idea of defining `Arc<T>` as `ARef<WithRef<T>>`. My
concern had to do with error messages for type aliases but you or
Benno (or Bjorn?) had a link to plans from the compiler team to
improve this. And we're using type aliases for our locks anyway.
So this change is in my queue. (As well as the changes to the guard we
discussed a couple of months ago.)
Thanks,
-Wedson