Trait concurrency_traits::TryThreadSpawner[][src]

pub trait TryThreadSpawner<O> where
    O: Send + 'static, 
{ type ThreadHandle: ThreadHandle; type SpawnError; fn try_spawn(
        func: impl FnOnce() -> O + 'static + Send
    ) -> Result<Self::ThreadHandle, Self::SpawnError>; }
Expand description

Functions to spawn new threads. If infallibility is required look to ThreadSpawner. If a result is needed from the launched thread look to TryResultThreadSpawner or ResultThreadSpawner. O is the result of the thread function.

Associated Types

type ThreadHandle: ThreadHandle[src]

The handle that is returned from spawning. Analog to std::thread::JoinHandle.

type SpawnError[src]

The error that can occur from starting the thread.

Required methods

fn try_spawn(
    func: impl FnOnce() -> O + 'static + Send
) -> Result<Self::ThreadHandle, Self::SpawnError>
[src]

Attempts to spawn a thread returning a result of Self::ThreadHandle and Self::SpawnError.

Implementors

impl<O> TryThreadSpawner<O> for StdThreadFunctions where
    O: Send + 'static, 
[src]

type ThreadHandle = JoinHandle<O>

type SpawnError = Infallible

fn try_spawn(
    func: impl FnOnce() -> O + 'static + Send
) -> Result<Self::ThreadHandle, Self::SpawnError>
[src]