Re: [PATCH v6 2/3] rust: sync: Introduce lock::Backend::Context
From: Trevor Gross
Date: Sun Sep 29 2024 - 16:40:57 EST
On Mon, Sep 16, 2024 at 5:31 PM Lyude Paul <lyude@xxxxxxxxxx> wrote:
>
> Now that we've introduced an `IrqDisabled` token for marking contexts in
> which IRQs are disabled, we need a way to be able to pass it to locks that
> require that IRQs are disabled. In order to continue using the
> `lock::Backend` type instead of inventing our own thing, we accomplish this
> by adding the associated Context type, along with a `lock_with()` function
> that can accept a Context when acquiring a lock. To allow current users of
> context-less locks to keep using the normal `lock()` method, we take an
> example from Wedson Almeida Filho's work and add a `where T<'a>: Default`
> bound to `lock()` so that it can only be called on lock types where the
> context is simply a placeholder value, then re-implement it through the new
> `lock_with()` function.
>
> Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
> Reviewed-by: Benno Lossin <benno.lossin@xxxxxxxxx>
> Reviewed-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
Reviewed-by: Trevor Gross <tmgross@xxxxxxxxx>