pub struct ResourceManager { /* private fields */ }Expand description
Resource manager
Implementations§
Source§impl ResourceManager
impl ResourceManager
Sourcepub fn new(config: ResourceConfig, quota: ResourceQuota) -> Self
pub fn new(config: ResourceConfig, quota: ResourceQuota) -> Self
Create newResource manager
Sourcepub fn check_resource_availability(
&self,
required: &ResourceUsage,
) -> RuntimeResult<bool>
pub fn check_resource_availability( &self, required: &ResourceUsage, ) -> RuntimeResult<bool>
Checkresourcewhetheravailable
Sourcepub fn allocate_resources(&mut self, usage: &ResourceUsage) -> RuntimeResult<()>
pub fn allocate_resources(&mut self, usage: &ResourceUsage) -> RuntimeResult<()>
Allocateresource
Sourcepub fn release_resources(&mut self, usage: &ResourceUsage) -> RuntimeResult<()>
pub fn release_resources(&mut self, usage: &ResourceUsage) -> RuntimeResult<()>
Releaseresource
Sourcepub fn get_usage(&self) -> &ResourceUsage
pub fn get_usage(&self) -> &ResourceUsage
GetcurrentResource usage
Sourcepub fn get_quota(&self) -> &ResourceQuota
pub fn get_quota(&self) -> &ResourceQuota
GetResource quota
Sourcepub fn calculate_usage_ratio(&self) -> ResourceUsageRatio
pub fn calculate_usage_ratio(&self) -> ResourceUsageRatio
compute resourcesusage rate
Auto Trait Implementations§
impl Freeze for ResourceManager
impl RefUnwindSafe for ResourceManager
impl Send for ResourceManager
impl Sync for ResourceManager
impl Unpin for ResourceManager
impl UnwindSafe for ResourceManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
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 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> ⓘ
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