pub struct WorkerTaskRunner<O: Default + 'static = (), P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P> = SingleTaskPool<O>>(/* private fields */);Expand description
工作者任务执行器
Implementations§
Source§impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> WorkerTaskRunner<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> WorkerTaskRunner<O, P>
Sourcepub fn new(
pool: P,
worker_status: Arc<AtomicBool>,
worker_waker: Arc<(AtomicBool, Mutex<()>, Condvar)>,
) -> Self
pub fn new( pool: P, worker_status: Arc<AtomicBool>, worker_waker: Arc<(AtomicBool, Mutex<()>, Condvar)>, ) -> Self
用指定的任务池构建工作者任务执行器
Sourcepub fn get_runtime(&self) -> WorkerRuntime<O, P>
pub fn get_runtime(&self) -> WorkerRuntime<O, P>
获取当前工作者异步任务执行器的工作者运行时
Sourcepub fn startup<LF, GQL>(
self,
thread_name: &str,
thread_stack_size: usize,
sleep_timeout: u64,
loop_interval: Option<u64>,
loop_func: LF,
get_queue_len: GQL,
) -> WorkerRuntime<O, P>where
P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>,
LF: Fn() -> (bool, Duration) + Send + 'static,
GQL: Fn() -> usize + Send + 'static,
pub fn startup<LF, GQL>(
self,
thread_name: &str,
thread_stack_size: usize,
sleep_timeout: u64,
loop_interval: Option<u64>,
loop_func: LF,
get_queue_len: GQL,
) -> WorkerRuntime<O, P>where
P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>,
LF: Fn() -> (bool, Duration) + Send + 'static,
GQL: Fn() -> usize + Send + 'static,
启动工作者异步任务执行器
Trait Implementations§
Source§impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> Clone for WorkerTaskRunner<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> Clone for WorkerTaskRunner<O, P>
Source§impl<O: Default + 'static> Default for WorkerTaskRunner<O>
impl<O: Default + 'static> Default for WorkerTaskRunner<O>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> Send for WorkerTaskRunner<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> Sync for WorkerTaskRunner<O, P>
Auto Trait Implementations§
impl<O, P> Freeze for WorkerTaskRunner<O, P>
impl<O = (), P = SingleTaskPool<O>> !RefUnwindSafe for WorkerTaskRunner<O, P>
impl<O, P> Unpin for WorkerTaskRunner<O, P>
impl<O = (), P = SingleTaskPool<O>> !UnwindSafe for WorkerTaskRunner<O, P>
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