use std::sync::{Arc, atomic::AtomicBool, mpsc};

use arc_swap::ArcSwap;

use crate::backend::processor::processor::ProcessorSnapshot;

use super::interrupts::Interrupt;

pub struct SharedState {
    pub proc: ArcSwap<ProcessorSnapshot>,

    pub reseting: AtomicBool,
    pub paused: AtomicBool,
    pub update_req: AtomicBool,
    pub interrupt_queue: mpsc::Sender<Interrupt>,
}

impl SharedState {
    pub fn new(sender: mpsc::Sender<Interrupt>) -> Self {
        Self {
            reseting: AtomicBool::new(false),
            proc: ArcSwap::new(Arc::new(ProcessorSnapshot::default())),

            paused: AtomicBool::new(true),
            interrupt_queue: sender,
            update_req: AtomicBool::new(false),
        }
    }
}
