use futures::Future; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; pub type Job = Box>; pub type JobSender = UnboundedSender; pub struct Scheduler { rx: UnboundedReceiver, } 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 } } }