aah/src/jobs.rs

24 lines
502 B
Rust
Raw Normal View History

2023-08-07 08:00:32 +00:00
use futures::Future;
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
pub type Job = Box<dyn Future<Output = ()>>;
pub type JobSender = UnboundedSender<Job>;
pub struct Scheduler {
rx: UnboundedReceiver<Job>,
}
impl Scheduler {
pub fn new() -> (Self, JobSender) {
let (tx, rx) = mpsc::unbounded_channel();
let scheduler = Scheduler { rx };
(scheduler, tx)
}
pub async fn run(self) {
loop {
// Get the next job, or if a new thing comes in
}
}
}