NAME
IO::Async::TimeQueue
- a queue of future timed event callbacks
DESCRIPTION
This class is not intended to be used by external code; it is used by IO::Async::Loop::Select
and IO::Async::Loop::IO_Poll
to implement the timer features.
CONSTRUCTOR
$queue = IO::Async::TimeQueue->new()
METHODS
$time = $queue->next_time
Returns the time of the next event on the queue, or undef
if no events are left.
$id = $queue->enqueue( %params )
Adds a new event to the queue. An ID value is returned, which may be passed to the cancel()
method to cancel this timer. This value may be an object reference, so care should be taken not to store it unless it is required. If it is stored, it should be released after the timer code has fired, or it has been canceled, in order to free the object itself.
The %params
takes the following keys:
- time => NUM
-
The absolute system timestamp to run the event.
- delay => NUM
-
The delay after now at which to run the event.
- now => NUM
-
The time to consider as now; defaults to
time()
if not specified. - code => CODE
-
CODE reference to the callback function to run at the allotted time.
Either time
or delay
must be specified.
$queue->cancel( $id )
Cancels a previously-enqueued timer event by removing it from the queue.
$count = $queue->fire( %params )
Call all the event callbacks that should have run by now. The number of callbacks actually invoked will be returned.
The %params
hash takes the following keys:
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>