Messages in this thread | | | Date | Wed, 9 Aug 2023 01:02:20 -0300 | Subject | Re: [RFC PATCH v1 3/5] rust: file: add `FileDescriptorReservation` | From | Martin Rodriguez Reboredo <> |
| |
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 { > [...] > +} > [...]
| |