beautiful compat worker implementation

This commit is contained in:
Quaternions 2023-10-24 19:09:39 -07:00
parent 4cf10dad78
commit 8113ede3e0
2 changed files with 22 additions and 0 deletions

21
src/compat_worker.rs Normal file
View File

@ -0,0 +1,21 @@
pub type QNWorker<Task>=CompatNWorker<Task>;
pub type INWorker<Task>=CompatNWorker<Task>;
pub struct CompatNWorker<Task>{
data:std::marker::PhantomData<Task>,
f:Box<dyn FnMut(Task)>,
}
impl<Task> CompatNWorker<Task>{
pub fn new(f:impl FnMut(Task))->Self{
Self{
data:std::marker::PhantomData,
f:Box::new(f),
}
}
pub fn send(&self,task:Task)->Result<(),()>{
(self.f)(task);
Ok(())
}
}

View File

@ -12,6 +12,7 @@ mod settings;
mod primitives; mod primitives;
mod instruction; mod instruction;
mod load_roblox; mod load_roblox;
mod compat_worker;
mod model_graphics; mod model_graphics;
mod physics_worker; mod physics_worker;
mod graphics_worker; mod graphics_worker;