pub struct TimerTaskWithCompletionNotifier { /* private fields */ }Expand description
Timer Task
Users interact via a two-step API
- Create task using
TimerTask::new_oneshot()orTimerTask::new_periodic() - Register task using
TimerWheel::register()orTimerService::register()
定时器任务
用户通过两步 API 与定时器交互
- 使用
TimerTask::new_oneshot()或TimerTask::new_periodic()创建任务 - 使用
TimerWheel::register()或TimerService::register()注册任务
Implementations§
Source§impl TimerTaskWithCompletionNotifier
impl TimerTaskWithCompletionNotifier
Sourcepub fn from_timer_task(task: TimerTask) -> (Self, CompletionReceiver)
pub fn from_timer_task(task: TimerTask) -> (Self, CompletionReceiver)
Create a new timer task with completion notifier from a timer task
从定时器任务创建一个新的定时器任务完成通知器
§Parameters
task: The timer task to create frombuffer_size: The buffer size for the periodic task completion notifier
§Returns
A tuple containing the new timer task with completion notifier and the completion receiver
返回一个包含新的定时器任务完成通知器和完成通知接收器的元组
Sourcepub fn get_id(&self) -> TaskId
pub fn get_id(&self) -> TaskId
Get task ID
获取任务 ID
§Examples (示例)
use kestrel_timer::TimerTask;
use std::time::Duration;
let task = TimerTask::new_oneshot(Duration::from_secs(1), None);
let task_id = task.get_id();
println!("Task ID: {:?}", task_id);Sourcepub fn into_task_type(self) -> TaskTypeWithCompletionNotifier
pub fn into_task_type(self) -> TaskTypeWithCompletionNotifier
Into task type
将任务类型转换为完成通知器
Sourcepub fn get_interval(&self) -> Option<Duration>
pub fn get_interval(&self) -> Option<Duration>
Get the interval for periodic tasks
Returns None for one-shot tasks
获取周期任务的间隔时间
对于一次性任务返回 None
Auto Trait Implementations§
impl Freeze for TimerTaskWithCompletionNotifier
impl !RefUnwindSafe for TimerTaskWithCompletionNotifier
impl Send for TimerTaskWithCompletionNotifier
impl Sync for TimerTaskWithCompletionNotifier
impl Unpin for TimerTaskWithCompletionNotifier
impl !UnwindSafe for TimerTaskWithCompletionNotifier
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