NAME
Linux::Event::Scheduler - Deadline scheduler (nanoseconds) for Linux::Event
SYNOPSIS
use Linux::Event::Clock;
use Linux::Event::Scheduler;
my $clock = Linux::Event::Clock->new(clock => 'monotonic');
my $sched = Linux::Event::Scheduler->new(clock => $clock);
$clock->tick;
$sched->after_ms(25, sub { say "fired" });
DESCRIPTION
Stores callbacks keyed by absolute deadlines in nanoseconds.
Pairs with:
Linux::Event::Clock for cached monotonic time and deadline math
Linux::Event::Timer (timerfd) for kernel wakeups in an event loop
This module does not block and does not manage file descriptors.
The scheduler stores callbacks, but the event loop decides the callback invocation signature.
STATUS
EXPERIMENTAL / WORK IN PROGRESS
The API is not yet considered stable and may change without notice.
CLOCK CONTRACT
Constructor accepts a duck-typed clock object which must implement:
now_nsdeadline_in_ns
The clock is expected to be ticked externally by the loop.
METHODS
new(clock => $clock)
at_ns($deadline_ns, $cb) -> $id
after_ns($delta_ns, $cb) -> $id
after_us($delta_us, $cb) -> $id
after_ms($delta_ms, $cb) -> $id
cancel($id) -> $bool
next_deadline_ns() -> $deadline_ns|undef
pop_expired() -> @items
Each item is:
[ $id, $coderef, $deadline_ns ]