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.
- code => CODE
-
CODE reference to the callback function to run at the allotted time.
$queue->cancel( $id )
Cancels a previously-enqueued timer event by removing it from the queue.
$newid = $queue->requeue( $id, %params )
Reschedule an existing timer, moving it to a new time. The old timer is removed and will not be invoked.
The %params
hash takes the same keys as enqueue()
, except for the code
argument.
The requeue operation may be implemented as a cancel + enqueue, which may mean the ID changes. Be sure to store the returned $newid
value if it is required.
$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>