pub struct ThreadPool { /* private fields */ }
Expand description
A general-purpose thread pool for scheduling asynchronous tasks.
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.
Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn new() -> Result<ThreadPool, Error>
pub fn new() -> Result<ThreadPool, Error>
Creates a new thread pool with the default configuration.
See documentation for the methods in
ThreadPoolBuilder
for details on the default
configuration.
Sourcepub fn builder() -> ThreadPoolBuilder
pub fn builder() -> ThreadPoolBuilder
Create a default thread pool configuration, which can then be customized.
See documentation for the methods in
ThreadPoolBuilder
for details on the default
configuration.
Sourcepub fn run<F: Future>(&mut self, f: F) -> Result<F::Item, F::Error>
pub fn run<F: Future>(&mut self, f: F) -> Result<F::Item, F::Error>
Runs the given future with this thread pool as the default executor for spawning tasks.
This function will block the calling thread until the given future is complete. While executing that future, any tasks spawned onto the default executor will be routed to this thread pool.
Note that the function will return when the provided future completes, even if some of the tasks it spawned are still running.
Trait Implementations§
Source§impl Clone for ThreadPool
impl Clone for ThreadPool
Source§fn clone(&self) -> ThreadPool
fn clone(&self) -> ThreadPool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ThreadPool
impl Debug for ThreadPool
Source§impl Drop for ThreadPool
impl Drop for ThreadPool
Source§impl Executor for ThreadPool
impl Executor for ThreadPool
Auto Trait Implementations§
impl Freeze for ThreadPool
impl RefUnwindSafe for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl UnwindSafe for ThreadPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more