Struct wasm_futures_executor::ThreadPool [−][src]
pub struct ThreadPool { /* fields omitted */ }
Expand description
A general-purpose thread pool for scheduling tasks that poll futures to completion.
The thread pool multiplexes any number of tasks onto a fixed number of worker threads.
This type is a clonable handle to the threadpool itself. Cloning it will only create a new reference, not a new threadpool.
The API follows futures_executor::ThreadPool
.
Implementations
Creates a new ThreadPool
with the provided count of web workers. The returned future
will resolve after all workers have spawned and are ready to accept work.
Creates a new ThreadPool
with Navigator.hardwareConcurrency
web workers.
Spawns a task that polls the given future with output ()
to
completion.
use wasm_futures_executor::ThreadPool;
let pool = ThreadPool::new().await.unwrap();
let future = async { /* ... */ };
pool.spawn_ok(future);
Spawns a task. This function returns a future which eventually resolves to the output of the computation. Note: The provided future is polled on the thread pool, no matter whether the returned future is polled or not.
Trait Implementations
Performs the conversion.
type Anchor = Ref<'static, ThreadPool>
type Anchor = Ref<'static, ThreadPool>
The type that holds the reference to Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous. Read more
Recover a Self::Anchor
from Self::Abi
. Read more
type Anchor = RefMut<'static, ThreadPool>
type Anchor = RefMut<'static, ThreadPool>
Same as RefFromWasmAbi::Anchor
Same as RefFromWasmAbi::ref_from_abi
Auto Trait Implementations
impl !RefUnwindSafe for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl !UnwindSafe for ThreadPool
Blanket Implementations
Mutably borrows from an owned value. Read more
type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
Same as IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
. Read more