[−][src]Struct scheduled_thread_pool::ScheduledThreadPool
A pool of threads which can run tasks at specific time intervals.
When the pool drops, all pending scheduled executions will be run, but periodic actions will not be rescheduled after that.
Methods
impl ScheduledThreadPool[src]
impl ScheduledThreadPoolpub fn new(num_threads: usize) -> ScheduledThreadPool[src]
pub fn new(num_threads: usize) -> ScheduledThreadPoolpub fn with_name(thread_name: &str, num_threads: usize) -> ScheduledThreadPool[src]
pub fn with_name(thread_name: &str, num_threads: usize) -> ScheduledThreadPoolCreates a new thread pool with the specified number of threads which will be named.
The substring {} in the name will be replaced with an integer
identifier of the thread.
Panics
Panics if num_threads is 0.
pub fn execute<F>(&self, job: F) -> JobHandle where
F: FnOnce() + Send + 'static, [src]
pub fn execute<F>(&self, job: F) -> JobHandle where
F: FnOnce() + Send + 'static, Executes a closure as soon as possible in the pool.
pub fn execute_after<F>(&self, delay: Duration, job: F) -> JobHandle where
F: FnOnce() + Send + 'static, [src]
pub fn execute_after<F>(&self, delay: Duration, job: F) -> JobHandle where
F: FnOnce() + Send + 'static, Executes a closure after a time delay in the pool.
pub fn execute_at_fixed_rate<F>(
&self,
initial_delay: Duration,
rate: Duration,
f: F
) -> JobHandle where
F: FnMut() + Send + 'static, [src]
pub fn execute_at_fixed_rate<F>(
&self,
initial_delay: Duration,
rate: Duration,
f: F
) -> JobHandle where
F: FnMut() + Send + 'static, Executes a closure after an initial delay at a fixed rate in the pool.
The rate includes the time spent running the closure. For example, if the rate is 5 seconds and the closure takes 2 seconds to run, the closure will be run again 3 seconds after it completes.
Panics
If the closure panics, it will not be run again.
pub fn execute_with_fixed_delay<F>(
&self,
initial_delay: Duration,
delay: Duration,
f: F
) -> JobHandle where
F: FnMut() + Send + 'static, [src]
pub fn execute_with_fixed_delay<F>(
&self,
initial_delay: Duration,
delay: Duration,
f: F
) -> JobHandle where
F: FnMut() + Send + 'static, Executes a closure after an initial delay at a fixed rate in the pool.
In contrast to execute_at_fixed_rate, the execution time of the
closure is not subtracted from the delay before it runs again. For
example, if the delay is 5 seconds and the closure takes 2 seconds to
run, the closure will run again 5 seconds after it completes.
Panics
If the closure panics, it will not be run again.
Trait Implementations
impl Drop for ScheduledThreadPool[src]
impl Drop for ScheduledThreadPoolAuto Trait Implementations
impl Send for ScheduledThreadPool
impl Send for ScheduledThreadPoolimpl Sync for ScheduledThreadPool
impl Sync for ScheduledThreadPoolBlanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeIdimpl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut T