pub fn spawn<F, R>(work: F) -> Result<OneShot<R>>
where
    F: FnOnce() -> R + Send + 'static,
    R: Send + 'static + Sized,
{
    SUBMITTED.fetch_add(1, Acquire);
    let (promise_filler, promise) = OneShot::pair();
    let task = move || {
        promise_filler.fill((work)());
    };

    let depth = QUEUE.send(Box::new(task));

    if depth > DESIRED_WAITING_THREADS {
        maybe_spawn_new_thread()?;
    }

    Ok(promise)
}
/// Spawn a function on the threadpool.
Spawn a function on the threadpool.
Spawn a function on the threadpool .
pub fn spawn<F, R>(work: F) -> Result<OneShot<R>>
where
    F: FnOnce() -> R + Send + 'static,
    R: Send + 'static + Sized,
{
    SUBMITTED.fetch_add(1, Acquire);
    let (promise_filler, promise) = OneShot::pair();
    let task = move || {
        promise_filler.fill((work)());
    };
    let depth = QUEUE.send(Box::new(task));
    if depth > DESIRED_WAITING_THREADS {
        maybe_spawn_new_thread()?;
    }
    Ok(promise)
}
pub fn spawn < F , R > ( work : F ) -> Result < OneShot < R > > where F : FnOnce ( ) -> R + Send + ' static , R : Send + ' static + Sized , { SUBMITTED . fetch_add ( 1 , Acquire ) ; let ( promise_filler , promise ) = OneShot :: pair ( ) ; let task = move | | { promise_filler . fill ( ( work ) ( ) ) ; } ; let depth = QUEUE . send ( Box :: new ( task ) ) ; if depth > DESIRED_WAITING_THREADS { maybe_spawn_new_thread ( ) ? ; } Ok ( promise ) }
Spawn a function on the threadpool.
Spawn a function on the threadpool .
work
F
work
F