1#![deny(missing_docs)]
3
4#[macro_use]
5extern crate log;
6
7use std::fmt;
8use std::sync::atomic::{AtomicU32, Ordering};
9
10pub mod channel;
11pub mod poll;
12pub mod queue;
13pub mod scheduler;
14
15static NEXT_NOTIFICATION_ID: AtomicU32 = AtomicU32::new(1);
16
17#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
19pub struct NotificationId(u32);
20
21impl NotificationId {
22 pub fn gen_next() -> NotificationId {
24 let id = NEXT_NOTIFICATION_ID.fetch_add(1, Ordering::SeqCst);
25 NotificationId(id)
26 }
27
28 pub fn id(&self) -> u32 {
30 self.0
31 }
32}
33
34impl fmt::Display for NotificationId {
35 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
36 write!(f, "{}", self.0)
37 }
38}