From ab276b517ba12f8ecdcc6caa7f12f244933bef72 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 19 Oct 2023 16:52:50 -0700 Subject: [PATCH] rename workers --- src/worker.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/worker.rs b/src/worker.rs index 8e66453..3d3862d 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -37,14 +37,21 @@ struct Description{ //The goal here is to have a worker thread that parks itself when it runs out of work. //The worker thread publishes the result of its work back to the worker object for every item in the work queue. +//Previous values do not matter as soon as a new value is produced, which is why it's called "Realtime" //The physics (target use case) knows when it has not changed the body, so not updating the value is also an option. -pub struct Worker { +/* +QR = WorkerDescription{ + input:Queued, + output:Realtime(Single), +} +*/ +pub struct QRWorker{ sender: mpsc::Sender, value:Arc>, } -impl Worker { +impl QRWorker{ pub fn newValue+Send+'static>(value:Value,mut f:F) -> Self { let (sender, receiver) = mpsc::channel::(); let ret=Self { @@ -78,13 +85,13 @@ impl Worker { } } -pub struct CompatWorker{ +pub struct CompatCRWorker{ data:std::marker::PhantomData, f:F, value:Value, } -implValue> CompatWorker { +implValue> CompatCRWorker{ pub fn new(value:Value,f:F) -> Self { Self { f, @@ -107,7 +114,7 @@ implValue> CompatWorker { fn test_worker() { println!("hiiiii"); // Create the worker thread - let worker = Worker::new(crate::physics::Body::with_pva(crate::integer::Planar64Vec3::ZERO,crate::integer::Planar64Vec3::ZERO,crate::integer::Planar64Vec3::ZERO), + let worker=CRWorker::new(crate::physics::Body::with_pva(crate::integer::Planar64Vec3::ZERO,crate::integer::Planar64Vec3::ZERO,crate::integer::Planar64Vec3::ZERO), |_|crate::physics::Body::with_pva(crate::integer::Planar64Vec3::ONE,crate::integer::Planar64Vec3::ONE,crate::integer::Planar64Vec3::ONE) );