wip kubipool

This commit is contained in:
griffi-gh 2023-11-19 19:30:06 +01:00
parent e40e394bd8
commit 9bdc38ccf0
5 changed files with 46 additions and 1 deletions

4
Cargo.lock generated
View file

@ -998,6 +998,10 @@ dependencies = [
"log",
]
[[package]]
name = "kubi-pool"
version = "0.0.0"
[[package]]
name = "kubi-server"
version = "0.0.0"

View file

@ -1,5 +1,5 @@
[workspace]
members = ["kubi", "kubi-server", "kubi-shared", "kubi-logging"]
members = ["kubi", "kubi-server", "kubi-shared", "kubi-logging", "kubi-pool"]
resolver = "2"
[profile.release-with-debug]

View file

@ -2,6 +2,7 @@
name = "kubi-logging"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
log = "0.4"

7
kubi-pool/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "kubi-pool"
version = "0.0.0"
edition = "2021"
publish = false
[dependencies]

33
kubi-pool/src/lib.rs Normal file
View file

@ -0,0 +1,33 @@
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 {
//todo
};
}
impl<T: 'static, R: 'static> KubiPool<T, R> {
pub fn new(threads: usize, callback: fn(T) -> R) -> Self {
Self {
callback,
threads: (0..threads).map(|_| {
std::thread::spawn(task_loop::<T, R>)
}).collect(),
}
}
pub fn resize(&mut self, threads: usize) {
}
}