24 lines
502 B
Rust
24 lines
502 B
Rust
|
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
|
||
|
}
|
||
|
}
|
||
|
}
|