Struct crossbeam_utils::thread::Scope
source · pub struct Scope<'env> { /* private fields */ }
Expand description
A scope for spawning threads.
Implementations§
source§impl<'env> Scope<'env>
impl<'env> Scope<'env>
sourcepub fn spawn<'scope, F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>where
F: FnOnce(&Scope<'env>) -> T + Send + 'env,
T: Send + 'env,
pub fn spawn<'scope, F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>where
F: FnOnce(&Scope<'env>) -> T + Send + 'env,
T: Send + 'env,
Create a scoped thread.
spawn
is similar to the spawn
function in Rust’s standard library. The difference is
that this thread is scoped, meaning that it’s guaranteed to terminate before the current
stack frame goes away, allowing you to reference the parent stack frame directly. This is
ensured by having the parent thread join on the child thread before the scope exits.
sourcepub fn builder<'scope>(&'scope self) -> ScopedThreadBuilder<'scope, 'env>
pub fn builder<'scope>(&'scope self) -> ScopedThreadBuilder<'scope, 'env>
Generates the base configuration for spawning a scoped thread, from which configuration methods can be chained.