Struct scope_threadpool::Scope
[−]
[src]
pub struct Scope<'pool, 'scope> { /* fields omitted */ }Represents the current scope, you can execute functions in it.
Methods
impl<'pool, 'scope> Scope<'pool, 'scope>[src]
fn with_state<StateMaker, State>(
self,
state_maker: StateMaker
) -> ScopeWithState<'pool, 'scope, State> where
StateMaker: Fn() -> State + Send + 'scope,
State: 'static, [src]
self,
state_maker: StateMaker
) -> ScopeWithState<'pool, 'scope, State> where
StateMaker: Fn() -> State + Send + 'scope,
State: 'static,
Give each of the threads a state
The parameter is a closure that is run in each thread. The parameter finishes running before this function exits.
A new scope is returned that allows one to run jobs in the worker threads which can take the state parameter.
fn execute<F>(&self, f: F) where
F: FnOnce() + Send + 'scope, [src]
F: FnOnce() + Send + 'scope,
Execute a job on one of the threads in the threadpool.
The closure is called from one of the threads. If the threadpool has a specified backlog, then this function blocks until the threadpool finishes a job.
This function may panic if a job that was previously
executed has panicked. This way, your program terminates
as soon as a panic occurs. If you don't call this function
again after a panic occurs, then Pool::scoped
will panic before it completes.