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
#![deny(missing_docs)]
extern crate crossbeam;
extern crate mio;
#[macro_use]
extern crate log;
use std::fmt;
use std::sync::atomic::{AtomicU32, Ordering};
pub mod channel;
pub mod poll;
pub mod queue;
pub mod scheduler;
static NEXT_NOTIFICATION_ID: AtomicU32 = AtomicU32::new(1);
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct NotificationId(u32);
impl NotificationId {
pub fn gen_next() -> NotificationId {
let id = NEXT_NOTIFICATION_ID.fetch_add(1, Ordering::SeqCst);
NotificationId(id)
}
pub fn id(&self) -> u32 {
self.0
}
}
impl fmt::Display for NotificationId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}