[−][src]Struct r_fairdist::Subscription
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]
A: Allocator<C::Scalar>,
C: Counter,
I: Clone + Ord,
pub fn charge(
&self,
slot: &C::Index,
amount: &C::Scalar
) -> Option<Charge<A, C, I>>
[src]
&self,
slot: &C::Index,
amount: &C::Scalar
) -> Option<Charge<A, C, I>>
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]
A: Allocator<C::Scalar>,
C: Counter,
I: Clone + Ord,
impl<A, C, I> Clone for Subscription<A, C, I> where
A: Allocator<C::Scalar>,
C: Counter,
I: Clone + Ord,
[src]
A: Allocator<C::Scalar>,
C: Counter,
I: Clone + Ord,
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]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,