pub struct Executors<F, T>{ /* private fields */ }
Implementations§
Source§impl<F, T> Executors<F, T>
impl<F, T> Executors<F, T>
Sourcepub fn new_fixed_thread_pool(
thread_count: u32,
) -> Result<ExecutorService<F, T>, ExecutorServiceError>
pub fn new_fixed_thread_pool( thread_count: u32, ) -> Result<ExecutorService<F, T>, ExecutorServiceError>
Creates a thread pool with a fixed size. All threads are initialized at first.
REMARKS
: The maximum value for [thread_count] is currently MAX_THREAD_COUNT
If you go beyond that, the function will fail, producing an ExecutorServiceError::ParameterError
Sourcepub fn new_cached_thread_pool(
initial_thread_count: Option<u32>,
) -> Result<ExecutorService<F, T>, ExecutorServiceError>
pub fn new_cached_thread_pool( initial_thread_count: Option<u32>, ) -> Result<ExecutorService<F, T>, ExecutorServiceError>
Creates a cached thread pool with an optional initial thread count. If the initial count is not provided, then a default of DEFAULT_INITIAL_CACHED_THREAD_COUNT threads will be initiated. When a new task is posted to the pool, if there are no threads available, then a new thread will be added to the pool and will then be cached. So the number of underlying threads is likely to increase with respect to the needs.
REMARKS
: The maximum value for initial_thread_count
is currently MAX_THREAD_COUNT. And
the maximum number of thread that can be created is also limited to MAX_THREAD_COUNT by design.
If more requests come and all threads are busy and we have a maximum of MAX_THREAD_COUNT threads,
then it will behave like a constant thread pool.