Skip to main content

luaur_analyze_cli/methods/
task_scheduler_task_scheduler_analyze.rs

1use crate::records::task_scheduler::{TaskQueue, TaskScheduler};
2use alloc::sync::Arc;
3use alloc::vec::Vec;
4
5impl TaskScheduler {
6    /// `TaskScheduler(unsigned threadCount)` (`CLI/src/Analyze.cpp:325-337`):
7    /// spawns `threadCount` worker threads, each running `workerFunction()`.
8    pub fn task_scheduler_task_scheduler(thread_count: u32) -> Self {
9        let tasks = Arc::new(TaskQueue::new());
10        let mut workers = Vec::with_capacity(thread_count as usize);
11
12        for _ in 0..thread_count {
13            let tasks = Arc::clone(&tasks);
14            let handle = std::thread::spawn(move || {
15                crate::methods::task_scheduler_worker_function::task_scheduler_worker_function(
16                    &tasks,
17                );
18            });
19            workers.push(handle);
20        }
21
22        TaskScheduler {
23            thread_count,
24            workers,
25            tasks,
26        }
27    }
28}