async_runtime/
priority.rs1use std::num::NonZeroUsize;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Priority {
6 High,
8 Normal,
10 Background,
12}
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub struct PriorityWeights {
17 high: NonZeroUsize,
18 normal: NonZeroUsize,
19 background: NonZeroUsize,
20}
21
22impl PriorityWeights {
23 pub const fn new(high: NonZeroUsize, normal: NonZeroUsize, background: NonZeroUsize) -> Self {
25 Self {
26 high,
27 normal,
28 background,
29 }
30 }
31
32 pub const fn high(self) -> NonZeroUsize {
34 self.high
35 }
36
37 pub const fn normal(self) -> NonZeroUsize {
39 self.normal
40 }
41
42 pub const fn background(self) -> NonZeroUsize {
44 self.background
45 }
46}
47
48impl Default for PriorityWeights {
49 fn default() -> Self {
50 Self::new(
51 NonZeroUsize::new(8).expect("8 is non-zero"),
52 NonZeroUsize::new(4).expect("4 is non-zero"),
53 NonZeroUsize::new(1).expect("1 is non-zero"),
54 )
55 }
56}