pub struct ThreadPoolExecutor { /* private fields */ }
Expand description
A ThreadPoolExecutor
will use one thread for the task scheduling and a thread pool for
task execution, allowing multiple tasks to run in parallel.
Implementations§
Source§impl ThreadPoolExecutor
impl ThreadPoolExecutor
Sourcepub fn new(threads: usize) -> Result<ThreadPoolExecutor, Error>
pub fn new(threads: usize) -> Result<ThreadPoolExecutor, Error>
Creates a new ThreadPoolExecutor
with the specified number of threads. Threads will
be named “pool_thread_0”, “pool_thread_1” and so on.
Sourcepub fn with_prefix(
threads: usize,
prefix: &str,
) -> Result<ThreadPoolExecutor, Error>
pub fn with_prefix( threads: usize, prefix: &str, ) -> Result<ThreadPoolExecutor, Error>
Creates a new ThreadPoolExecutor
with the specified number of threads and prefix for
the thread names.
Sourcepub fn with_executor(
threads: usize,
prefix: &str,
executor: CoreExecutor,
) -> ThreadPoolExecutor
pub fn with_executor( threads: usize, prefix: &str, executor: CoreExecutor, ) -> ThreadPoolExecutor
Creates a new ThreadPoolExecutor
with the specified number of threads, prefix and
using the given CoreExecutor
for scheduling.
Sourcepub fn schedule_fixed_rate<F>(
&self,
initial: Duration,
interval: Duration,
scheduled_fn: F,
) -> TaskHandle
pub fn schedule_fixed_rate<F>( &self, initial: Duration, interval: Duration, scheduled_fn: F, ) -> TaskHandle
Schedules the given function to be executed every interval
. The function will be
scheduled on one of the threads in the thread pool.
Trait Implementations§
Source§impl Clone for ThreadPoolExecutor
impl Clone for ThreadPoolExecutor
Source§fn clone(&self) -> ThreadPoolExecutor
fn clone(&self) -> ThreadPoolExecutor
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ThreadPoolExecutor
impl !RefUnwindSafe for ThreadPoolExecutor
impl Send for ThreadPoolExecutor
impl Sync for ThreadPoolExecutor
impl Unpin for ThreadPoolExecutor
impl !UnwindSafe for ThreadPoolExecutor
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
Mutably borrows from an owned value. Read more