use std::sync::atomic::Ordering;

use crate::services::{Services, with_services};

impl Services {
    fn unique_id(&self) -> usize {
        self.tso.fetch_add(1, Ordering::Relaxed)
    }
}

/// Generates a globally unique monotonic ID.
pub fn unique_id() -> usize {
    with_services(|services| services.unique_id())
}
