• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ekarpp / lumo / 14235426927

03 Apr 2025 03:53AM UTC coverage: 72.653%. First build
14235426927

push

github

ekarpp
0.6.1

* Generalize thread pool
* Paralellize material parsing for scenes
* Implement variable wavelength index of refraction (and dispersion)
* Implement efficiency optimized russian roulette
* Add batching to samplers
* Restricts mediums to scene boundaries
* Fix cylinder bounding box
* Fix instance sample on normals
* Update github actions

290 of 821 new or added lines in 36 files covered. (35.32%)

6740 of 9277 relevant lines covered (72.65%)

39613243.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/pool.rs
1
use std::sync::{Arc, mpsc, Mutex};
2

3
mod queue;
4
mod worker;
5

6
pub trait Executor<T, R>: Clone + Send + Sync + 'static {
7
    fn exec(&mut self, task: T) -> R;
8
}
9

10
pub struct ThreadPool<T, R> {
11
    workers: Vec<worker::Worker>,
12
    task_tx: mpsc::Sender<Option<T>>,
13
    result_queue: queue::RenderQueue<Option<R>>,
14
}
15

16
impl<T: Send + Sync + 'static, R: Send + Sync + 'static> ThreadPool<T, R> {
NEW
17
    pub fn new<E: Executor<T, R>>(
×
NEW
18
        workers: usize,
×
NEW
19
        executor: E,
×
NEW
20
    ) -> Self {
×
NEW
21
        assert!(workers > 0);
×
22

NEW
23
        let (result_queue, result_tx) = queue::RenderQueue::<Option<R>>::new();
×
NEW
24
        let (task_queue, task_tx) = queue::RenderQueue::<Option<T>>::new();
×
NEW
25
        // shared between workers, wrap it in a mutex arc
×
NEW
26
        let task_queue = Arc::new(Mutex::new(task_queue));
×
NEW
27

×
NEW
28
        let workers = (0..workers)
×
NEW
29
            .map(|i| worker::Worker::new(
×
NEW
30
                i,
×
NEW
31
                result_tx.clone(),
×
NEW
32
                Arc::clone(&task_queue),
×
NEW
33
                executor.clone(),
×
NEW
34
            ))
×
NEW
35
            .collect();
×
NEW
36

×
NEW
37
        Self { workers, task_tx, result_queue }
×
NEW
38
    }
×
39

40
    /// Publish `task` to the pool
NEW
41
    pub fn publish(&self, task: T) {
×
NEW
42
        self.task_tx.send(Some(task)).unwrap();
×
NEW
43
    }
×
44

45
    /// Inform workers that all tasks are published
NEW
46
    pub fn all_published(&self) {
×
NEW
47
        for _ in 0..self.workers.len() {
×
NEW
48
            self.task_tx.send(None).unwrap()
×
49
        }
NEW
50
    }
×
51

NEW
52
    pub fn pop_result(&self) -> Option<R> {
×
NEW
53
        self.result_queue.pop()
×
NEW
54
    }
×
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc