pub enum ExceedLimitPolicy {
Wait,
Reject,
CallerRuns,
}Expand description
The policy that can be set when the task submited exceed the maximum size of the Threadpool.
Variants§
Wait
The task will wait until some workers are idle.
Reject
The task will be rejected, A TaskRejected ExecutorError will be given.
let pool = threadpool_executor::threadpool::Builder::new()
.core_pool_size(1)
.maximum_pool_size(1)
.exeed_limit_policy(threadpool_executor::threadpool::ExceedLimitPolicy::Reject)
.build();
let res = pool.execute(|| {
std::thread::sleep(std::time::Duration::from_secs(10));
});
assert!(res.is_ok());
let res = pool.execute(|| "a");
assert!(res.is_err());
if let Err(err) = res {
matches!(err.kind(), threadpool_executor::error::ErrorKind::TaskRejected);
}CallerRuns
The task will be run in the caller’s thread, and will run immediatly.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExceedLimitPolicy
impl RefUnwindSafe for ExceedLimitPolicy
impl Send for ExceedLimitPolicy
impl Sync for ExceedLimitPolicy
impl Unpin for ExceedLimitPolicy
impl UnwindSafe for ExceedLimitPolicy
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