pub struct DelayedQueue<T: Send + Sync + Clone + 'static> { /* private fields */ }Expand description
延迟任务队列
管理延迟执行的任务,支持优先级排序。
Implementations§
Source§impl<T: Send + Sync + Clone + 'static> DelayedQueue<T>
impl<T: Send + Sync + Clone + 'static> DelayedQueue<T>
Sourcepub fn new<E: DelayedTaskExecutor<T> + 'static>(
config: DelayedQueueConfig,
executor: Arc<E>,
) -> Self
pub fn new<E: DelayedTaskExecutor<T> + 'static>( config: DelayedQueueConfig, executor: Arc<E>, ) -> Self
创建新的延迟任务队列
Sourcepub async fn schedule_delayed(
&self,
task: DelayedTask<T>,
) -> WaeResult<TaskHandle>
pub async fn schedule_delayed( &self, task: DelayedTask<T>, ) -> WaeResult<TaskHandle>
Sourcepub async fn queue_size(&self) -> usize
pub async fn queue_size(&self) -> usize
获取队列大小
Sourcepub async fn cancel_task(&self, task_id: &str) -> WaeResult<bool>
pub async fn cancel_task(&self, task_id: &str) -> WaeResult<bool>
取消任务
Sourcepub async fn get_handle(&self, task_id: &str) -> Option<TaskHandle>
pub async fn get_handle(&self, task_id: &str) -> Option<TaskHandle>
获取任务句柄
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
检查是否已关闭
Auto Trait Implementations§
impl<T> Freeze for DelayedQueue<T>
impl<T> !RefUnwindSafe for DelayedQueue<T>
impl<T> Send for DelayedQueue<T>
impl<T> Sync for DelayedQueue<T>
impl<T> Unpin for DelayedQueue<T>
impl<T> UnsafeUnpin for DelayedQueue<T>
impl<T> !UnwindSafe for DelayedQueue<T>
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