pub struct Scope<'scope, 'env>where
'env: 'scope,{ /* private fields */ }
Expand description
A scope to spawn scoped threads in.
See scope
for details.
Implementations§
source§impl<'scope, 'env> Scope<'scope, 'env>
impl<'scope, 'env> Scope<'scope, 'env>
1.63.0 · sourcepub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>
Available on crate feature std
only.
pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>
std
only.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 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 call will create a thread using default parameters of Builder
.
If you want to specify the stack size or the name of the thread, use
Builder::spawn_scoped
instead.
§Panics
Panics if the OS fails to create a thread; use Builder::spawn_scoped
to recover from such errors.
Trait Implementations§
Auto Trait Implementations§
impl<'scope, 'env> Freeze for Scope<'scope, 'env>
impl<'scope, 'env> RefUnwindSafe for Scope<'scope, 'env>
impl<'scope, 'env> Send for Scope<'scope, 'env>
impl<'scope, 'env> Sync for Scope<'scope, 'env>
impl<'scope, 'env> Unpin for Scope<'scope, 'env>
impl<'scope, 'env> !UnwindSafe for Scope<'scope, 'env>
Blanket Implementations§
source§impl<T> Also for T
impl<T> Also for T
source§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> ByteSized for T
impl<T> ByteSized for T
source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
source§const LITTLE_ENDIAN: bool = true
const LITTLE_ENDIAN: bool = true
source§const BIG_ENDIAN: bool = false
const BIG_ENDIAN: bool = false
source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
source§impl<T> ExtAny for T
impl<T> ExtAny for T
source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moresource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moresource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
source§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.