Struct ReservationImpl

Source
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>

Source

pub fn new(owner: T, owner_object_id: Option<u64>, amount: u64) -> Self

Source

pub fn owner_object_id(&self) -> Option<u64>

Source

pub fn amount(&self) -> u64

Returns the total amount of the reservation, not accounting for anything that might be held.

Source

pub fn add(&self, amount: u64)

Adds more to the reservation.

Source

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).

Source

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.

Source

pub fn reserve(&self, amount: u64) -> Option<ReservationImpl<&Self, Self>>

Reserves exactly amount if possible.

Source

pub fn commit(&self, amount: u64)

Commits a previously reserved amount from this reservation. The caller is responsible for ensuring the amount was reserved.

Source

pub fn give_back(&self, amount: u64)

Returns some of the reservation.

Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Borrow<U>, U: ReservationOwner + ?Sized> Drop for ReservationImpl<T, U>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Borrow<U> + Send + Sync, U: ReservationOwner + ?Sized> ReservationOwner for ReservationImpl<T, U>

Source§

fn release_reservation(&self, owner_object_id: Option<u64>, amount: u64)

Report that bytes are being released from the reservation back to the the |ReservationOwner| where |owner_object_id| is the owner under the root object store associated with the reservation.

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>
where T: Send, U: ?Sized,

§

impl<T, U> Sync for ReservationImpl<T, U>
where T: Sync, U: ?Sized,

§

impl<T, U> Unpin for ReservationImpl<T, U>
where T: Unpin, U: Unpin + ?Sized,

§

impl<T, U> UnwindSafe for ReservationImpl<T, U>
where T: UnwindSafe, U: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V