use super::*;

mod query; pub use query::SupervisorQuery;
mod internal; use internal::Internal;

pub struct Supervisor {
    channel:Sender<Query>,
}

impl Supervisor {
    
}

impl Subsystem for Supervisor {
    fn start(_supervisor:Option<Sender<Query>>) -> Result<Sender<Query>, crate::Error>
    {
        let (tx, rx) = channel::bounded::<Query>(24);

        let sys_tx = tx.clone();
        std::thread::spawn(move || {
            Internal::thread(sys_tx, rx);
        });

        Ok(tx)
    }
}

impl From<Sender<Query>> for Supervisor {
    fn from(channel:Sender<Query>) -> Self {
        Self { channel }
    }
}
