Event::Watcher::Tied#
The base class for watcher types written in Perl. A subclass makes its watchers with allocate, and the loop calls back into it:
_start($w, $repeat)- required; called bystart($repeatfalse) andagain(true). It must arrange for events, by queueing them withEvent::queueor by settingat._alarm($w)- called when the time set withathas come; required onceatis used._stop($w)- called bystop, if the subclass has it.
The shared watcher methods and attributes are Event::Watcher’s.
Synopsis#
package My::Ticker;
use base 'Event::Watcher::Tied';
sub new {
my ($class, %arg) = @_;
my $w = $class->allocate({});
$w->init(\%arg);
$w;
}
sub _start { my ($w) = @_; $w->at(Event::time() + 1) }
sub _alarm { my ($w) = @_; Event::queue($w); $w->at(Event::time() + 1) }
Functions#
Construction#
allocate#
Make a new, inactive watcher blessed into $class, a subclass; $template, a hash or array reference, becomes the object. Dies “Bad template” when it is no reference. The subclass’s constructor then usually calls init (see Event::Watcher).
Attributes#
hard#
The flag timers use to choose how to reckon their next time (see Event::timer). A tied watcher’s own _start and _alarm decide its times, so here it is only stored, for them to read.
at#
The time _alarm is to be called, in the units of Event::time. Setting a time schedules the alarm, replacing a scheduled one; setting undef only cancels it.
flags#
The watcher’s state bits ACTIVE (1) and SUSPEND (4) (see Event::Watcher). Setting it can change only the bit 0x4000, which is on by default: a repeating watcher with it on stops generating events while its callback runs. Trying to change any other bit warns “Other flags (0xN) cannot be changed”.