Function crossbeam_utils::thread::scope[][src]

pub fn scope<'a, F, R>(f: F) -> R where
    F: FnOnce(&Scope<'a>) -> R, 

Create a new scope, for deferred destructors.

Scopes, in particular, support scoped thread spawning.

Examples

Creating and using a scope:

crossbeam_utils::thread::scope(|scope| {
    scope.defer(|| println!("Exiting scope"));
    scope.spawn(|| println!("Running child thread in scope"))
});
// Prints messages in the reverse order written

Panics

thread::scope() panics if a spawned thread panics but it is not joined inside the scope.