1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::MAX_POOLS;
use std::{error::Error, fmt};
#[derive(Debug)]
pub enum SwitchyardCreationError {
InvalidPoolIndex {
thread_idx: usize,
pool_idx: u8,
total_pools: u8,
},
TooManyPools {
pools_requested: u8,
},
InvalidAffinity {
affinity: usize,
total_threads: usize,
},
}
impl fmt::Display for SwitchyardCreationError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Self::InvalidPoolIndex {
thread_idx,
pool_idx,
total_pools,
} => write!(
f,
"Thread index {} requested job pool {} but there are only {} pools",
thread_idx, pool_idx, total_pools
),
Self::TooManyPools { pools_requested } => write!(
f,
"Requested {} pools which is greater than the max {}",
pools_requested, MAX_POOLS
),
Self::InvalidAffinity {
affinity,
total_threads,
} => write!(
f,
"Requested affinity {} which is greater than total logical core count {}",
affinity, total_threads
),
}
}
}
impl Error for SwitchyardCreationError {}