# [−][src]Struct crossbeam::thread::Scope

    pub struct Scope<'env> where
        'env: 'env,  { /* fields omitted */ }

A scope for spawning threads.

## Methods

### `impl<'env> Scope<'env>`[src]

#### `pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> where
F: FnOnce(&Scope<'env>) -> T + Send + 'env,
T: Send + 'env,` [src]

Spawns a scoped thread.

This method is similar to the `spawn` function in Rust's standard library. The difference is that this thread is scoped, meaning it's guaranteed to terminate before the scope exits, allowing it to reference variables outside the scope.

The scoped thread is passed a reference to this scope as an argument, which can be used for spawning nested threads.

The returned handle can be used to manually join the thread before the scope exits.

# Examples

    use crossbeam_utils::thread;

    thread::scope(|s| {
        let handle = s.spawn(|_| {
            println!("A child thread is running");
            42
        });

        // Join the thread and retrieve its result.
        let res = handle.join().unwrap();
        assert_eq!(res, 42);
    }).unwrap();

#### `pub fn builder(&'scope self) -> ScopedThreadBuilder<'scope, 'env>`[src]

Creates a builder that can configure a thread before spawning.

# Examples

    use crossbeam_utils::thread;
    use std::thread::current;

    thread::scope(|s| {
        s.builder()
            .spawn(|_| println!("A child thread is running"))
            .unwrap();
    }).unwrap();

## Trait Implementations

### `impl<'env> Debug for Scope<'env>`[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result<(), Error>`[src]

Formats the value using the given formatter. Read more

### `impl<'env> Sync for Scope<'env>`[src]

## Auto Trait Implementations

### `impl<'env> Send for Scope<'env>`

### `impl<'env> Unpin for Scope<'env>`

### `impl<'env> !UnwindSafe for Scope<'env>`

### `impl<'env> !RefUnwindSafe for Scope<'env>`

## Blanket Implementations

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `fn into(self) -> U`[src]

Performs the conversion.

### `impl<T> From<T> for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut W

### Important traits for &'_ mut W

`impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow_mut(&mut self) -> &mut T`[src]

Mutably borrows from an owned value. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut W

### Important traits for &'_ mut W

`impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)