gloo_worker/actor/handler_id.rs
1use std::sync::atomic::{AtomicUsize, Ordering};
2
3use serde::{Deserialize, Serialize};
4
5/// Identifier to send output to bridges.
6#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Hash, Clone, Copy)]
7pub struct HandlerId(usize);
8
9impl HandlerId {
10 pub(crate) fn new() -> Self {
11 static CTR: AtomicUsize = AtomicUsize::new(0);
12
13 let id = CTR.fetch_add(1, Ordering::SeqCst);
14
15 HandlerId(id)
16 }
17}