forked from StrafesNET/strafe-client
beautiful compat worker implementation
This commit is contained in:
parent
4cf10dad78
commit
8113ede3e0
21
src/compat_worker.rs
Normal file
21
src/compat_worker.rs
Normal 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(())
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user