2023-11-19 12:30:06 -06:00
|
|
|
use std::{thread::JoinHandle, collections::VecDeque};
|
|
|
|
|
|
|
|
pub struct KubiPool<T, R> {
|
|
|
|
callback: fn(T) -> R,
|
|
|
|
threads: Vec<JoinHandle<()>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Task<T> {
|
|
|
|
priority: u8,
|
|
|
|
data: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn task_loop<T, R>() {
|
|
|
|
let tasks = VecDeque::<Task<T>>::new();
|
|
|
|
loop {
|
2023-11-20 12:51:16 -06:00
|
|
|
|
2023-11-19 12:30:06 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: 'static, R: 'static> KubiPool<T, R> {
|
|
|
|
pub fn new(threads: usize, callback: fn(T) -> R) -> Self {
|
|
|
|
Self {
|
|
|
|
callback,
|
|
|
|
threads: (0..threads).map(|_| {
|
2023-11-20 12:51:16 -06:00
|
|
|
std::thread::spawn(move || task_loop::<T, R>())
|
2023-11-19 12:30:06 -06:00
|
|
|
}).collect(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn resize(&mut self, threads: usize) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|