2023-10-18 17:17:21 -07:00
|
|
|
pub type QNWorker<'a,Task>=CompatNWorker<'a,Task>;
|
|
|
|
pub type INWorker<'a,Task>=CompatNWorker<'a,Task>;
|
|
|
|
|
|
|
|
pub struct CompatNWorker<'a,Task>{
|
|
|
|
data:std::marker::PhantomData<Task>,
|
2025-01-02 22:01:43 -08:00
|
|
|
f:Box<dyn FnMut(Task)+'a>,
|
2023-10-18 17:17:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a,Task> CompatNWorker<'a,Task>{
|
2025-01-02 22:01:43 -08:00
|
|
|
pub fn new(f:impl FnMut(Task)+'a)->CompatNWorker<'a,Task>{
|
2023-10-18 17:17:21 -07:00
|
|
|
Self{
|
|
|
|
data:std::marker::PhantomData,
|
|
|
|
f:Box::new(f),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn send(&mut self,task:Task)->Result<(),()>{
|
|
|
|
(self.f)(task);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|