1use std::time::Duration;
4
5#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
7pub struct RuntimeConfig {
8 pub thread_count: Option<usize>,
13
14 pub signal_delivery: SignalDeliveryConfig,
16}
17
18#[derive(Clone, Copy, Debug, Eq, PartialEq)]
20pub struct SignalDeliveryConfig {
21 pub ready_timeout: Duration,
23
24 pub max_enqueue_attempts: u32,
26
27 pub initial_backoff: Duration,
29
30 pub max_backoff: Duration,
32}
33
34impl Default for SignalDeliveryConfig {
35 fn default() -> Self {
36 Self::new(
37 Duration::from_millis(50),
38 8,
39 Duration::from_millis(1),
40 Duration::from_millis(8),
41 )
42 }
43}
44
45impl SignalDeliveryConfig {
46 #[must_use]
48 pub const fn new(
49 ready_timeout: Duration,
50 max_enqueue_attempts: u32,
51 initial_backoff: Duration,
52 max_backoff: Duration,
53 ) -> Self {
54 Self {
55 ready_timeout,
56 max_enqueue_attempts,
57 initial_backoff,
58 max_backoff,
59 }
60 }
61}
62
63impl RuntimeConfig {
64 #[must_use]
66 pub fn new(thread_count: Option<usize>) -> Self {
67 Self {
68 thread_count,
69 signal_delivery: SignalDeliveryConfig::default(),
70 }
71 }
72
73 #[must_use]
75 pub const fn with_signal_delivery(mut self, signal_delivery: SignalDeliveryConfig) -> Self {
76 self.signal_delivery = signal_delivery;
77 self
78 }
79}