pub fn spawn<T>(&self, task: T) -> Job<T::Output>
    where
        T: Future + Send + 'static,
        T::Output: Send + 'static,
    {
        let (tx, rx) = tokio::sync::oneshot::channel();

        let fut = Box::pin(async move {
            let task_output = task.await;
            if tx.send(task_output).is_err() {
                warn!("Spawned task output ignored: receiver dropped")
            }
        });
        let cancel = CancellationToken::new();
        let mut state = self.state.lock();
        let task = Task {
            fut,
            cancel: cancel.clone(),
            task_ref: Arc::clone(&state.task_refs),
        };

        if let Some(requests) = &mut state.requests {
            // would fail if someone has started shutdown
            requests.send(task).ok();
        } else {
            warn!("tried to schedule task on an executor that was shutdown");
        }

        Job {
            rx,
            cancel,
            detached: false,
        }
    }
/// Runs the specified Future (and any tasks it spawns) on the
/// `DedicatedExecutor`.
///
/// Currently all tasks are added to the tokio executor
/// immediately and compete for the threadpool's resources.
Runs the specified Future (and any tasks it spawns) on the
`DedicatedExecutor`.

Currently all tasks are added to the tokio executor
immediately and compete for the threadpool's resources.
Runs the specified Future ( and any tasks it spawns ) on the ` DedicatedExecutor ` . Currently all tasks are added to the tokio executor immediately and compete for the threadpool ' s resources .
pub fn spawn<T>(&self, task: T) -> Job<T::Output>
    where
        T: Future + Send + 'static,
        T::Output: Send + 'static,
    {
        let (tx, rx) = tokio::sync::oneshot::channel();
        let fut = Box::pin(async move {
            let task_output = task.await;
            if tx.send(task_output).is_err() {
                warn!("Spawned task output ignored: receiver dropped")
            }
        });
        let cancel = CancellationToken::new();
        let mut state = self.state.lock();
        let task = Task {
            fut,
            cancel: cancel.clone(),
            task_ref: Arc::clone(&state.task_refs),
        };
        if let Some(requests) = &mut state.requests {
            // would fail if someone has started shutdown
            requests.send(task).ok();
        } else {
            warn!("tried to schedule task on an executor that was shutdown");
        }
        Job {
            rx,
            cancel,
            detached: false,
        }
    }
pub fn spawn < T > ( & self , task : T ) -> Job < T :: Output > where T : Future + Send + ' static , T :: Output : Send + ' static , { let ( tx , rx ) = tokio :: sync :: oneshot :: channel ( ) ; let fut = Box :: pin ( async move { let task_output = task . await ; if tx . send ( task_output ) . is_err ( ) { warn ! ( " " ) } } ) ; let cancel = CancellationToken :: new ( ) ; let mut state = self . state . lock ( ) ; let task = Task { fut , cancel : cancel . clone ( ) , task_ref : Arc :: clone ( & state . task_refs ) , } ; if let Some ( requests ) = & mut state . requests { // would fail if someone has started shutdown requests . send ( task ) . ok ( ) ; } else { warn ! ( " " ) ; } Job { rx , cancel , detached : false , } }
Runs the specified Future (and any tasks it spawns) on the
`DedicatedExecutor`.
Runs the specified Future ( and any tasks it spawns ) on the ` DedicatedExecutor ` .
&self
task
T
&self
task
T