pub struct PriorityConfig { /* private fields */ }Expand description
Configuration for priority-based queue strategies.
Implementations§
Source§impl PriorityConfig
impl PriorityConfig
Sourcepub fn default_strategy(self, strategy: QueueStrategy) -> Self
pub fn default_strategy(self, strategy: QueueStrategy) -> Self
Set the default queue strategy for all priorities not matched by other rules.
Sourcepub fn exact(self, priority: isize, strategy: QueueStrategy) -> Self
pub fn exact(self, priority: isize, strategy: QueueStrategy) -> Self
Set the queue strategy for an exact priority value.
Sourcepub fn greater_or_equal(self, threshold: isize, strategy: QueueStrategy) -> Self
pub fn greater_or_equal(self, threshold: isize, strategy: QueueStrategy) -> Self
Set the queue strategy for priorities greater than or equal to the threshold. This is a convenience method that creates a range [threshold, isize::MAX].
Sourcepub fn greater_than(self, threshold: isize, strategy: QueueStrategy) -> Self
pub fn greater_than(self, threshold: isize, strategy: QueueStrategy) -> Self
Set the queue strategy for priorities greater than the threshold (exclusive). This is a convenience method that creates a range [threshold + 1, isize::MAX].
Sourcepub fn less_or_equal(self, threshold: isize, strategy: QueueStrategy) -> Self
pub fn less_or_equal(self, threshold: isize, strategy: QueueStrategy) -> Self
Set the queue strategy for priorities less than or equal to the threshold. This is a convenience method that creates a range [isize::MIN, threshold].
Sourcepub fn less_than(self, threshold: isize, strategy: QueueStrategy) -> Self
pub fn less_than(self, threshold: isize, strategy: QueueStrategy) -> Self
Set the queue strategy for priorities less than the threshold (exclusive). This is a convenience method that creates a range [isize::MIN, threshold - 1].
Sourcepub fn range(self, min: isize, max: isize, strategy: QueueStrategy) -> Self
pub fn range(self, min: isize, max: isize, strategy: QueueStrategy) -> Self
Set the queue strategy for priorities within a range [min, max] (inclusive).
Sourcepub fn strategy_for_priority(&self, priority: isize) -> QueueStrategy
pub fn strategy_for_priority(&self, priority: isize) -> QueueStrategy
Returns the queue strategy that would be used for the given priority.
This method evaluates all configured rules to determine which queue strategy (FIFO or LIFO) would be applied to a waiter with the specified priority.
§Arguments
priority- The priority level to query
§Returns
The QueueStrategy that would be used for the given priority.
§Examples
use ranked_semaphore::{PriorityConfig, QueueStrategy};
let config = PriorityConfig::new()
.default_strategy(QueueStrategy::Fifo)
.exact(10, QueueStrategy::Lifo);
assert_eq!(config.strategy_for_priority(5), QueueStrategy::Fifo);
assert_eq!(config.strategy_for_priority(10), QueueStrategy::Lifo);Trait Implementations§
Source§impl Clone for PriorityConfig
impl Clone for PriorityConfig
Source§fn clone(&self) -> PriorityConfig
fn clone(&self) -> PriorityConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more