Re: sudden features
[email protected] (Jochen Stenzel)
| Newsgroups | perl.loop |
|---|---|
| Message-ID | <[email protected]> |
> Well, some sort of test for the test suite would suffice. The code
> isn't really finished so I'm sure you'll be feeling the rough edges soon
> enough.
Hm, I got a (reproducable) core dump in first tests. Then, surprisingly, after
a slight restructuring, the script behaved as excepted. I attach both variants
(these are not intended as demos, of course ;-).
Jochen
gtest.coredump.pl
(application/x-perl, 444 B)
#!./perl -w
use strict;
use Event qw(time);
require Event::group;
my @varWatchers;
foreach (1..10)
{
no strict 'refs';
push(@varWatchers, Event->var(var=>\${"var$_"}, cb=>sub {warn "Changed var $_.\n"}, poll=>'rw'));
}
my $groupWatcher=Event->group(parked=>1, timeout => 2, cb => sub {my $e = shift; warn "All vars are still unchanged.\n";});
$groupWatcher->add($_) foreach (@varWatchers);
$groupWatcher->start;
Event::loop();
gtest.pl
(application/x-perl, 513 B)
#!./perl -w
use strict;
use Event qw(time);
require Event::group;
# prepare group watcher
my $groupWatcher=Event->group(parked=>1, timeout => 2, cb => sub {my $e = shift; warn "All vars are still unchanged.\n";});
# install several var watchers and made them watched by the group watcher
foreach (1..10)
{
no strict 'refs';
$groupWatcher->add(Event->var(var=>\${"var$_"}, cb=>sub {warn "Changed var $_.\n"}, poll=>'rw'));
}
# activate group watcher
$groupWatcher->start;
# start loop
Event::loop();