Trait ThreadSpawner

Source
pub trait ThreadSpawner<O>: TryThreadSpawner<O, SpawnError = Infallible>
where O: Send + 'static,
{ // Provided method fn spawn(func: impl FnOnce() -> O + 'static + Send) -> Self::ThreadHandle { ... } }
Expand description

Same as a TryThreadSpawner with an Infallible TryThreadSpawner::SpawnError. This is auto-implemented with TryThreadSpawner when possible. If a result is needed from the launched thread look to ResultThreadSpawner.

Provided Methods§

Source

fn spawn(func: impl FnOnce() -> O + 'static + Send) -> Self::ThreadHandle

Spawns a thread returning a TryThreadSpawner::ThreadHandle. Analog to std::thread::spawn. Will be faster on nightly due to Result::unwrap_unchecked.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, O> ThreadSpawner<O> for T
where T: TryThreadSpawner<O, SpawnError = Infallible>, O: Send + 'static,