pub struct TimerService { /* private fields */ }Expand description
Timer service: one-shot and repeating timers with message delivery.
Registered as a SystemService alongside CronService.
Timers deliver messages to the owner’s PID via the A2A router
(or whatever delivery mechanism is wired at the kernel level).
Implementations§
Source§impl TimerService
impl TimerService
Sourcepub fn new() -> TimerService
pub fn new() -> TimerService
Create a new timer service.
Sourcepub fn create_oneshot(
&self,
owner_pid: u64,
delay: Duration,
payload: MessagePayload,
) -> (String, CancellationToken)
pub fn create_oneshot( &self, owner_pid: u64, delay: Duration, payload: MessagePayload, ) -> (String, CancellationToken)
Create a one-shot timer.
Returns the timer ID and a cancellation token. The timer fires
after delay and delivers a message with the given payload.
Sourcepub fn create_repeating(
&self,
owner_pid: u64,
interval: Duration,
payload: MessagePayload,
) -> (String, CancellationToken)
pub fn create_repeating( &self, owner_pid: u64, interval: Duration, payload: MessagePayload, ) -> (String, CancellationToken)
Create a repeating timer.
Returns the timer ID and a cancellation token. The timer fires
every interval starting after the first interval elapses.
Sourcepub fn cancel(&self, timer_id: &str) -> bool
pub fn cancel(&self, timer_id: &str) -> bool
Cancel a timer by ID.
Returns true if the timer was found and cancelled.
Sourcepub fn cancel_for_pid(&self, pid: u64) -> usize
pub fn cancel_for_pid(&self, pid: u64) -> usize
Cancel all timers owned by a specific PID.
Called when an agent exits to clean up its timers. Returns the number of timers cancelled.
Sourcepub fn remove(&self, timer_id: &str) -> Option<TimerEntry>
pub fn remove(&self, timer_id: &str) -> Option<TimerEntry>
Remove a timer from the registry (after it fires or is cancelled).
Sourcepub fn cleanup_cancelled(&self) -> usize
pub fn cleanup_cancelled(&self) -> usize
Remove all cancelled timers from the registry.
Sourcepub fn list_for_pid(&self, pid: u64) -> Vec<TimerInfo>
pub fn list_for_pid(&self, pid: u64) -> Vec<TimerInfo>
List timers owned by a specific PID.
Sourcepub fn collect_due(&self) -> Vec<(u64, KernelMessage)>
pub fn collect_due(&self) -> Vec<(u64, KernelMessage)>
Check which timers are due to fire.
Returns timer entries that have passed their fire_at time and have not been cancelled. One-shot timers are removed; repeating timers have their fire_at updated.
Trait Implementations§
Source§impl Default for TimerService
impl Default for TimerService
Source§fn default() -> TimerService
fn default() -> TimerService
Auto Trait Implementations§
impl !Freeze for TimerService
impl !RefUnwindSafe for TimerService
impl Send for TimerService
impl Sync for TimerService
impl Unpin for TimerService
impl UnsafeUnpin for TimerService
impl UnwindSafe for TimerService
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more