Scope in std::thread - Rust (original) (raw)
Struct Scope
1.63.0 · Source
pub struct Scope<'scope, 'env: 'scope> { /* private fields */ }Expand description
A scope to spawn scoped threads in.
See scope for details.
1.63.0 · Source
Spawns a new thread within a scope, returning a ScopedJoinHandle for it.
Unlike non-scoped threads, threads spawned with this function may borrow non-'static data from the outside the scope. See scope for details.
The join handle provides a join method that can be used to join the spawned thread. If the spawned thread panics, join will return an Err containing the panic payload.
If the join handle is dropped, the spawned thread will be implicitly joined at the end of the scope. In that case, if the spawned thread panics, scope will panic after all threads are joined.
This function creates a thread with the default parameters of Builder. To specify the new thread’s stack size or the name, use Builder::spawn_scoped.
§Panics
Panics if the OS fails to create a thread; use Builder::spawn_scopedto recover from such errors.