diff options
Diffstat (limited to 'src/render/coordinator.rs')
-rw-r--r-- | src/render/coordinator.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/render/coordinator.rs b/src/render/coordinator.rs index a9a7d06..a8d8afb 100644 --- a/src/render/coordinator.rs +++ b/src/render/coordinator.rs @@ -7,7 +7,8 @@ use crate::camera::Film; use crate::core::{Bound2i, Vector2i}; use crate::sample::Sampler; -use std::sync::Mutex; +use std::sync::{Arc, Mutex}; +use std::thread; struct Tiler { tilesize: Vector2i, @@ -112,4 +113,15 @@ impl<'a> RenderCoord<'a> { self.finish_task(&task); } } + + pub fn run_threaded(&self, ctx: &RenderContext, sampler: &mut (dyn Sampler + Send), threads: u32) { + crossbeam::scope(|scope| { + for _ in 0..threads { + let mut sampler = sampler.clone_and_seed(); + scope.spawn(move |_| { + self.work(ctx, sampler.as_mut()); + }); + } + }).unwrap(); + } } |