pub struct PendingTask {
pub task_id: u32,
start: Box<dyn FnOnce() -> tokio::task::JoinHandle<()> + Send>,
}
impl PendingTask {
pub fn new<F>(task_id: u32, start: F) -> Self
where
F: FnOnce() -> tokio::task::JoinHandle<()> + Send + 'static,
{
Self {
task_id,
start: Box::new(start),
}
}
pub fn spawn(self) -> tokio::task::JoinHandle<()> {
(self.start)()
}
}