tinyflow-framework 0.1.0

Streaming runtime engine — checkpoint, chained task execution, and state store
Documentation
//! Deferred task launch for chain execution (collect then spawn).

/// Prepared task: call [`PendingTask::spawn`] to start on the runtime.
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)()
    }
}