mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-23 15:28:44 -06:00
wip kubipool
This commit is contained in:
parent
e40e394bd8
commit
9bdc38ccf0
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -998,6 +998,10 @@ dependencies = [
|
|||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kubi-pool"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "kubi-server"
|
||||
version = "0.0.0"
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
7
kubi-pool/Cargo.toml
Normal 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
33
kubi-pool/src/lib.rs
Normal 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) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue