atomr_core/dispatch/
mailbox.rs1use std::time::Duration;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
10pub enum MailboxKind {
11 #[default]
12 Unbounded,
13 Bounded,
14 UnboundedDeque,
15 UnboundedPriority,
16 UnboundedStablePriority,
17}
18
19#[derive(Debug, Clone)]
20pub struct MailboxConfig {
21 pub kind: MailboxKind,
22 pub capacity: usize,
23 pub push_timeout: Duration,
24}
25
26impl Default for MailboxConfig {
27 fn default() -> Self {
28 Self { kind: MailboxKind::Unbounded, capacity: 1_000, push_timeout: Duration::from_secs(10) }
29 }
30}
31
32#[derive(Debug, Clone, Default)]
35pub struct Mailbox {
36 pub config: MailboxConfig,
37}
38
39impl Mailbox {
40 pub fn new(config: MailboxConfig) -> Self {
41 Self { config }
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn default_mailbox_kind_unbounded() {
51 assert_eq!(Mailbox::default().config.kind, MailboxKind::Unbounded);
52 }
53}