Skip to main content

radiate_core/domain/
mod.rs

1pub mod executor;
2pub mod math;
3pub mod random_provider;
4pub mod sync;
5pub mod tracker;
6
7pub use executor::Executor;
8pub use math::SubsetMode;
9pub use math::subset;
10pub use random_provider::RdRand;
11pub use sync::{CommandChannel, MutCell, WaitGroup, WaitGuard, get_thread_pool};
12
13#[macro_export]
14macro_rules! sentry_id {
15    ($name:ident) => {
16        #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17        #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18        #[repr(transparent)]
19        pub struct $name(u64);
20
21        impl $name {
22            pub const EMPTY: Self = $name(0);
23
24            pub fn new() -> Self {
25                use std::sync::atomic::Ordering;
26
27                static COUNTER: AtomicU64 = AtomicU64::new(1);
28                $name(COUNTER.fetch_add(1, Ordering::Relaxed))
29            }
30
31            pub const fn is_empty(&self) -> bool {
32                self.0 == 0
33            }
34
35            pub const fn get(&self) -> u64 {
36                self.0
37            }
38        }
39
40        #[allow(clippy::from_over_into)]
41        impl Into<u64> for $name {
42            fn into(self) -> u64 {
43                self.0
44            }
45        }
46
47        impl AsRef<u64> for $name {
48            fn as_ref(&self) -> &u64 {
49                &self.0
50            }
51        }
52
53        impl Default for $name {
54            fn default() -> Self {
55                Self::EMPTY
56            }
57        }
58    };
59}