use std::sync::Arc; use tokio::sync::Mutex; use crate::workers::{Signal,SignalData,Pointer}; use tokio::sync::Notify; pub struct QueResponse{ signal:Arc>, sleeper:Arc } impl QueResponse{ pub fn new(signal:Arc>,sleeper:Arc)->QueResponse{ QueResponse{ signal:signal, sleeper:sleeper } } pub async fn check(&self)->bool{ self.sleeper.notified().await; if !Signal::check(&self.signal).await{ return false; } else { return true; } } pub async fn data(self)->Option<(Vec,Pointer)>{ match Signal::get(self.signal).await{ Ok(v)=>{ match v{ SignalData::Value(v)=>{ Some(v) }, _=>{None} } }, Err(_)=>{ return None; } } } }