pub struct ReservationImpl<T: Borrow<U>, U: ReservationOwner + ?Sized> { /* private fields */ }
Expand description
A reservation guarantees that when it comes time to actually allocate, it will not fail due to
lack of space. Sub-reservations (a.k.a. holds) are possible which effectively allows part of a
reservation to be set aside until it’s time to commit. Reservations do offer some
thread-safety, but some responsibility is born by the caller: e.g. calling forget
and
reserve
at the same time from different threads is unsafe. Reservations are have an
|owner_object_id| which associates it with an object under the root object store that the
reservation is accounted against.
Implementations§
Source§impl<T: Borrow<U> + Clone + Send + Sync, U: ReservationOwner + ?Sized> ReservationImpl<T, U>
impl<T: Borrow<U> + Clone + Send + Sync, U: ReservationOwner + ?Sized> ReservationImpl<T, U>
pub fn new(owner: T, owner_object_id: Option<u64>, amount: u64) -> Self
pub fn owner_object_id(&self) -> Option<u64>
Sourcepub fn amount(&self) -> u64
pub fn amount(&self) -> u64
Returns the total amount of the reservation, not accounting for anything that might be held.
Sourcepub fn forget(&self) -> u64
pub fn forget(&self) -> u64
Returns the entire amount of the reservation. The caller is responsible for maintaining consistency, i.e. updating counters, etc, and there can be no sub-reservations (an assert will fire otherwise).
Sourcepub fn forget_some(&self, amount: u64)
pub fn forget_some(&self, amount: u64)
Takes some of the reservation. The caller is responsible for maintaining consistency, i.e. updating counters, etc. This will assert that the amount being forgotten does not exceed the available reservation amount; the caller should ensure that this is the case.
Sourcepub fn reserve(&self, amount: u64) -> Option<ReservationImpl<&Self, Self>>
pub fn reserve(&self, amount: u64) -> Option<ReservationImpl<&Self, Self>>
Reserves exactly amount if possible.
Sourcepub fn commit(&self, amount: u64)
pub fn commit(&self, amount: u64)
Commits a previously reserved amount from this reservation. The caller is responsible for ensuring the amount was reserved.
Sourcepub fn move_to<V: Borrow<W> + Clone + Send + Sync, W: ReservationOwner + ?Sized>(
&self,
other: &ReservationImpl<V, W>,
amount: u64,
)
pub fn move_to<V: Borrow<W> + Clone + Send + Sync, W: ReservationOwner + ?Sized>( &self, other: &ReservationImpl<V, W>, amount: u64, )
Moves amount
from this reservation to another reservation.
Trait Implementations§
Source§impl<T: Borrow<U>, U: ReservationOwner + ?Sized> Debug for ReservationImpl<T, U>
impl<T: Borrow<U>, U: ReservationOwner + ?Sized> Debug for ReservationImpl<T, U>
Source§impl<T: Borrow<U>, U: ReservationOwner + ?Sized> Drop for ReservationImpl<T, U>
impl<T: Borrow<U>, U: ReservationOwner + ?Sized> Drop for ReservationImpl<T, U>
Source§impl<T: Borrow<U> + Send + Sync, U: ReservationOwner + ?Sized> ReservationOwner for ReservationImpl<T, U>
impl<T: Borrow<U> + Send + Sync, U: ReservationOwner + ?Sized> ReservationOwner for ReservationImpl<T, U>
Auto Trait Implementations§
impl<T, U> !Freeze for ReservationImpl<T, U>
impl<T, U> !RefUnwindSafe for ReservationImpl<T, U>
impl<T, U> Send for ReservationImpl<T, U>
impl<T, U> Sync for ReservationImpl<T, U>
impl<T, U> Unpin for ReservationImpl<T, U>
impl<T, U> UnwindSafe for ReservationImpl<T, U>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more