use crate::arch::x86_64::memory::allocation::stack_alloc::StackBounds;
use x86_64::VirtAddr;

mod switch;

#[derive(Debug)]
pub struct Thread {
    id: ThreadId,
    stack_ptr: Option<VirtAddr>,
    stack_bounds: Option<StackBounds>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct ThreadId(u64);

impl ThreadId {
    pub const fn as_u64(&self) -> u64 {
        self.0
    }

    fn new() -> Self {
        use core::sync::atomic::{AtomicU64, Ordering};
        static NEXT_THREAD_ID: AtomicU64 = AtomicU64::new(1);
        Self(NEXT_THREAD_ID.fetch_add(1, Ordering::Relaxed))
    }
}
