From 8113ede3e0f0231a13f3e2ca71b30a4e5aa70850 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 24 Oct 2023 19:09:39 -0700 Subject: [PATCH] beautiful compat worker implementation --- src/compat_worker.rs | 21 +++++++++++++++++++++ src/main.rs | 1 + 2 files changed, 22 insertions(+) create mode 100644 src/compat_worker.rs diff --git a/src/compat_worker.rs b/src/compat_worker.rs new file mode 100644 index 0000000..1a87005 --- /dev/null +++ b/src/compat_worker.rs @@ -0,0 +1,21 @@ +pub type QNWorker=CompatNWorker; +pub type INWorker=CompatNWorker; + +pub struct CompatNWorker{ + data:std::marker::PhantomData, + f:Box, +} + +impl CompatNWorker{ + 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(()) + } +} diff --git a/src/main.rs b/src/main.rs index d36476b..ad920d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ mod settings; mod primitives; mod instruction; mod load_roblox; +mod compat_worker; mod model_graphics; mod physics_worker; mod graphics_worker;