lkml.org 
[lkml]   [2023]   [Aug]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH v1 3/5] rust: file: add `FileDescriptorReservation`
From
On 7/20/23 12:28, Alice Ryhl wrote:
> From: Wedson Almeida Filho <walmeida@microsoft.com>
>
> This allows the creation of a file descriptor in two steps: first, we
> reserve a slot for it, then we commit or drop the reservation. The first
> step may fail (e.g., the current process ran out of available slots),
> but commit and drop never fail (and are mutually exclusive).
>
> Co-Developed-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> [...]
> +/// A file descriptor reservation.
> +///
> +/// This allows the creation of a file descriptor in two steps: first, we reserve a slot for it,
> +/// then we commit or drop the reservation. The first step may fail (e.g., the current process ran
> +/// out of available slots), but commit and drop never fail (and are mutually exclusive).

This "drop" suggests to me that there was a method that it does said
action, and indeed it is `Drop::drop`. But if I look at the doc comment
of `commit` then it doesn't look that these two are mutex.

/// Commits the reservation.
///
/// The previously reserved file descriptor is bound to `file`.

I'd put a mention that `FileDescriptorReservation` gets forgotten when
`commit` is called so then it clears up that it's mutex with drop.

> +///
> +/// # Invariants
> +///
> +/// The fd stored in this struct must correspond to a reserved file descriptor of the current task.
> +pub struct FileDescriptorReservation {
> [...]
> +}
> [...]

\
 
 \ /
  Last update: 2023-08-09 06:35    [W:0.065 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site