Hi all,
I'm sure I'm missing something fundamental here, but ... when should
timer watchers be destroyed? I would expect the following:
#! perl -w
use Event;
sub DESTROY { warn "gone $_[0]" }
sub ping { warn "ping $_[0]" }
{
my $obj={};
bless $obj;
Event->timer(after => 1,
cb => sub { $obj->ping() });
}
{
my $obj={};
bless $obj;
Event->timer(after => 2,
cb => sub { $obj->ping() });
}
Event::loop();
__END__
to give output like
<pause 1 sec>
ping main=HASH(0x815dbb8) at test2.pl line 6.
gone main=HASH(0x815dbb8) at test2.pl line 5.
<pause 1 sec>
ping main=HASH(0x8222358) at test2.pl line 6.
gone main=HASH(0x8222358) at test2.pl line 5.
<program ends>
but in fact, it does this:
<pause 1 sec>
ping main=HASH(0x815dbb8) at test2.pl line 6.
<pause 1 sec>
ping main=HASH(0x8222358) at test2.pl line 6.
gone main=HASH(0x815dbb8) at test2.pl line 5.
gone main=HASH(0x8222358) at test2.pl line 5.
<program ends>
Using NetServer::Portal::Top, both of my timers are listed as zombies:
EID PRI STATE RAN TIME CPU TYPE DESCRIPTION
P1
0 7 2 0:04100.0% sys idle
1 3 sleep 1 0:00 0.0% time Event::Stats
2 3 cpu 0 0:00 0.0% io NetServer::Portal::Client debian
3 4 zomb 0 0:00 0.0% time ?? test2.pl:23
4 4 zomb 0 0:00 0.0% time ?? test2.pl:17
5 3 sleep 0 0:00 0.0% io NetServer::Portal
6 5 wait 0 0:00 0.0% idle NetServer::Portal /var/tmp/test2pl.npc
0 -1 0 0:00 0.0% sys other processes
(and in this case, the objects are never destroyed, presumably because
the portal is keeping the event loop running). I tried setting up a
second timer to explicitly cancel the first, and indeed this works,
but it's rather messy!
Is it possible to do what I want, and make the watcher objects be
destroyed when they have fired? (From the example above, you can see
a hint as to why I'm wanting this -- I want an expiring object to
register a timer, to feed back news of its death to a parent, and then
go automatically out of scope and DESTROY itself).
This is the Debian packaging of Event, version 0.87-1, with perl
5.8.3-3.
Many thanks,
Andy
--
Andy Mortimer [EMAIL PROTECTED]
--
Andy walking, Andy tired,
Andy take a little snooze
-- "Andy Warhol," David Bowie