Struct devela::_libstd::thread::Scope

1.63.0 · source ·
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>

1.63.0 · source

pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T>
where F: FnOnce() -> T + Send + 'scope, T: Send + 'scope,

Available on crate feature 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§

1.63.0 · source§

impl Debug for Scope<'_, '_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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

source§

fn also_mut<F: FnOnce(&mut Self)>(self, f: F) -> Self

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
source§

fn also_ref<F: FnOnce(&Self)>(self, f: F) -> Self

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T, Res> Apply<Res> for T
where T: ?Sized,

source§

fn apply<F: FnOnce(Self) -> Res>(self, f: F) -> Res
where Self: Sized,

Apply a function which takes the parameter by value.
source§

fn apply_ref<F: FnOnce(&Self) -> Res>(&self, f: F) -> Res

Apply a function which takes the parameter by shared reference.
source§

fn apply_mut<F: FnOnce(&mut Self) -> Res>(&mut self, f: F) -> Res

Apply a function which takes the parameter by exclusive reference.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> ByteSized for T

source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
source§

const PTR_BYTES: usize = 8usize

The size of a pointer in bytes, for the current platform.
source§

const PTR_BITS: usize = 64usize

The size of a pointer in bits, for the current platform.
source§

const LITTLE_ENDIAN: bool = true

True if the system’s architecture is little-endian.
source§

const BIG_ENDIAN: bool = false

True if the system’s architecture is big-endian.
source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between PTR_BYTES and BYTE_SIZE. Read more
source§

impl<T> ExtAny for T
where T: Any + ?Sized,

source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. Read more
source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Available on crate feature unsafe_dyn only.
Returns some shared reference to the inner value if it is of type T. Read more
source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Available on crate feature unsafe_dyn only.
Returns some exclusive reference to the inner value if it is of type T. Read more
source§

impl<T> ExtMem for T
where T: ?Sized,

source§

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8].
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.