pub struct Scope<'scope, 'env: 'scope> { /* private fields */ }
Expand description
A scope to submit closures in.
See scope
for details.
Implementations§
Methods from Deref<Target = Pool>§
Sourcepub fn set_thread_limits(&self, min: u32, max: u32)
pub fn set_thread_limits(&self, min: u32, max: u32)
Sets the thread limits for the Pool
object.
Sourcepub fn submit<F: FnOnce() + Send + 'static>(&self, f: F)
pub fn submit<F: FnOnce() + Send + 'static>(&self, f: F)
Submit the closure to the thread pool.
- The closure must have
'static
lifetime as the thread may outlive the lifetime in whichsubmit
is called. - The closure must be
Send
as it will be sent to another thread for execution.
Sourcepub fn scope<'env, F>(&self, f: F)
pub fn scope<'env, F>(&self, f: F)
Create a scope for submitting closures.
Within this scope local variables can be sent to the pool thread for execution.
This is possible because scope
will wait for all submitted closures to finish before returning,
Note however that it will also wait for closures that were submitted from other threads.
Trait Implementations§
Auto Trait Implementations§
impl<'scope, 'env> Freeze for Scope<'scope, 'env>
impl<'scope, 'env> RefUnwindSafe for Scope<'scope, 'env>
impl<'scope, 'env> Send for Scope<'scope, 'env>
impl<'scope, 'env> Sync for Scope<'scope, 'env>
impl<'scope, 'env> Unpin for Scope<'scope, 'env>
impl<'scope, 'env> !UnwindSafe for Scope<'scope, 'env>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more