Struct ScopedThreadBuilder
pub struct ScopedThreadBuilder<'scope, 'env> { /* private fields */ }
Configures the properties of a new thread.
The two configurable properties are:
name: Specifies an associated name for the thread.stack_size: Specifies the desired stack size for the thread.
The spawn method will take ownership of the builder and return an io::Result of the
thread handle with the given configuration.
The Scope::spawn method uses a builder with default configuration and unwraps its return
value. You may want to use this builder when you want to recover from a failure to launch a
thread.
Examples
use thread;
scope.unwrap;
Implementations
impl<'scope, 'env> ScopedThreadBuilder<'scope, 'env>
fn name(self, name: String) -> ScopedThreadBuilder<'scope, 'env>Sets the name for the new thread.
The name must not contain null bytes (
\0).For more information about named threads, see here.
Examples
use thread; use current; scope.unwrap;fn stack_size(self, size: usize) -> ScopedThreadBuilder<'scope, 'env>Sets the size of the stack for the new thread.
The stack size is measured in bytes.
For more information about the stack size for threads, see here.
Examples
use thread; scope.unwrap;fn spawn<F, T>(self, f: F) -> Result<ScopedJoinHandle<'scope, T>> where F: FnOnce(&Scope<'env>) -> T + Send + 'env, T: Send + 'env,Spawns a scoped thread with this configuration.
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.
Errors
Unlike the
Scope::spawnmethod, this method yields anio::Resultto capture any failure to create the thread at the OS level.Panics
Panics if a thread name was set and it contained null bytes.
Examples
use thread; scope.unwrap;
Trait Implementations
impl<'scope, 'env> Debug for ScopedThreadBuilder<'scope, 'env>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<'scope, 'env> Freeze for ScopedThreadBuilder<'scope, 'env>
impl<'scope, 'env> RefUnwindSafe for ScopedThreadBuilder<'scope, 'env>
impl<'scope, 'env> Send for ScopedThreadBuilder<'scope, 'env>
impl<'scope, 'env> Sync for ScopedThreadBuilder<'scope, 'env>
impl<'scope, 'env> Unpin for ScopedThreadBuilder<'scope, 'env>
impl<'scope, 'env> UnsafeUnpin for ScopedThreadBuilder<'scope, 'env>
impl<'scope, 'env> UnwindSafe for ScopedThreadBuilder<'scope, 'env>
Blanket Implementations
impl<T> Any for ScopedThreadBuilder<'scope, 'env>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ScopedThreadBuilder<'scope, 'env>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ScopedThreadBuilder<'scope, 'env>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for ScopedThreadBuilder<'scope, 'env>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for ScopedThreadBuilder<'scope, 'env>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ScopedThreadBuilder<'scope, 'env>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for ScopedThreadBuilder<'scope, 'env>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>