# [−][src]Crate scoped_threadpool

This crate provides a stable, safe and scoped threadpool.

It can be used to execute a number of short-lived jobs in parallel without the need to respawn the underlying threads.

Jobs are runnable by borrowing the pool for a given scope, during which an arbitrary number of them can be executed. These jobs can access data of any lifetime outside of the pools scope, which allows working on non-`'static` references in parallel.

For safety reasons, a panic inside a worker thread will not be isolated, but rather propagate to the outside of the pool.

# Examples:

    extern crate scoped_threadpool;
    use scoped_threadpool::Pool;

    fn main() {
        // Create a threadpool holding 4 threads
        let mut pool = Pool::new(4);

        let mut vec = vec![0, 1, 2, 3, 4, 5, 6, 7];

        // Use the threads as scoped threads that can
        // reference anything outside this closure
        pool.scoped(|scope| {
            // Create references to each element in the vector ...
            for e in &mut vec {
                // ... and add 1 to it in a seperate thread
                scope.execute(move || {
                    *e += 1;
                });
            }
        });

        assert_eq!(vec, vec![1, 2, 3, 4, 5, 6, 7, 8]);
    }

## Structs

Pool | A threadpool that acts as a handle to a number of threads spawned at construction.
Scope | Handle to the scope during which the threadpool is borrowed.

# 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`)