[][src]Struct r_fairdist::Subscription

pub struct Subscription<A, C, I> where
    A: Allocator<C::Scalar>,
    C: Counter,
    I: Clone + Ord
{ /* fields omitted */ }

A subscription to a resource.

A subscription allows to perform continous allocations on a resource. A subscription is simply the combination of a resource and the user ID to perform accesses as. That is, a subscription can be created from a resource by providing the user ID to subscribe as. All subscriptions of different user IDs are distinct, but subscriptions with the same user ID reference the same underlying usage table.

To request resource from a resource registry, you have to subscribe to it first. This subscription is then used to request the resources in a charge. The subscription is pinned in every charge, so there is no need for the caller to cache it. However, if continuous charges are required, caching the subscription will skip a map lookup on every charge. Furthermore, as long as a subscription is alive, the underlying resource registry consider the subscriber to be interested in the resources. The resource allocation will thus be able to improve the fairness of the resource distribution, because it can better estimate how many users are interested in resources.

Methods

impl<A, C, I> Subscription<A, C, I> where
    A: Allocator<C::Scalar>,
    C: Counter,
    I: Clone + Ord
[src]

pub fn charge(
    &self,
    slot: &C::Index,
    amount: &C::Scalar
) -> Option<Charge<A, C, I>>
[src]

Create a new charge.

This is a shortcut for creating a new [Charge] object and calling [Charge::charge()]. If the charge request succeeds, this function returns the [Charge] object. Otherwise, None is returned.

Trait Implementations

impl<A, C, I> Drop for Subscription<A, C, I> where
    A: Allocator<C::Scalar>,
    C: Counter,
    I: Clone + Ord
[src]

impl<A, C, I> Clone for Subscription<A, C, I> where
    A: Allocator<C::Scalar>,
    C: Counter,
    I: Clone + Ord
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<A, C, I> !Send for Subscription<A, C, I>

impl<A, C, I> !Sync for Subscription<A, C, I>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]