pub struct ThrottlePolicy { /* private fields */ }Expand description
Maps (priority, pressure) pairs to throttle decisions.
Contains a list of thresholds: a task at or below a given priority (higher numeric value = lower priority) is throttled when pressure exceeds the associated limit.
Thresholds are evaluated from lowest priority to highest. The first matching rule applies.
Implementations§
Source§impl ThrottlePolicy
impl ThrottlePolicy
Sourcepub fn new(thresholds: Vec<(Priority, f32)>) -> Self
pub fn new(thresholds: Vec<(Priority, f32)>) -> Self
Create a policy with custom thresholds.
Each (priority, limit) means: any task with priority value >= priority
(i.e. lower or equal priority) is throttled when pressure > limit.
Thresholds should be ordered from lowest priority to highest.
Sourcepub fn default_three_tier() -> Self
pub fn default_three_tier() -> Self
Default three-tier policy matching Shoebox’s original behavior:
- BACKGROUND (192+): pause at >50% pressure
- NORMAL (128+): pause at >75% pressure
- Everything else: never pause
Sourcepub fn should_throttle(&self, priority: Priority, pressure: f32) -> bool
pub fn should_throttle(&self, priority: Priority, pressure: f32) -> bool
Should a task at this priority be throttled given current pressure?
Auto Trait Implementations§
impl Freeze for ThrottlePolicy
impl RefUnwindSafe for ThrottlePolicy
impl Send for ThrottlePolicy
impl Sync for ThrottlePolicy
impl Unpin for ThrottlePolicy
impl UnsafeUnpin for ThrottlePolicy
impl UnwindSafe for ThrottlePolicy
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
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