mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-23 23:38:42 -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",
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kubi-pool"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kubi-server"
|
name = "kubi-server"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["kubi", "kubi-server", "kubi-shared", "kubi-logging"]
|
members = ["kubi", "kubi-server", "kubi-shared", "kubi-logging", "kubi-pool"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[profile.release-with-debug]
|
[profile.release-with-debug]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
name = "kubi-logging"
|
name = "kubi-logging"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
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