Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Events/Perl/events-1.pl
Normal file
31
Task/Events/Perl/events-1.pl
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use AnyEvent;
|
||||
|
||||
# a new condition with a callback:
|
||||
my $quit = AnyEvent->condvar(
|
||||
cb => sub {
|
||||
warn "Bye!\n";
|
||||
}
|
||||
);
|
||||
|
||||
# a new timer, starts after 2s and repeats every 0.25s:
|
||||
my $counter = 1;
|
||||
my $hi = AnyEvent->timer(
|
||||
after => 2,
|
||||
interval => 0.25,
|
||||
cb => sub {
|
||||
warn "Hi!\n";
|
||||
# flag the condition as ready after 4 times:
|
||||
$quit->send if ++$counter > 4;
|
||||
}
|
||||
);
|
||||
|
||||
# another timer, runs the callback once after 1s:
|
||||
my $hello = AnyEvent->timer(
|
||||
after => 1,
|
||||
cb => sub {
|
||||
warn "Hello world!\n";
|
||||
}
|
||||
);
|
||||
|
||||
# wait for the $quit condition to be ready:
|
||||
$quit->recv();
|
||||
15
Task/Events/Perl/events-2.pl
Normal file
15
Task/Events/Perl/events-2.pl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use AnyEvent;
|
||||
|
||||
my $quit = AE::cv sub { warn "Bye!\n" };
|
||||
|
||||
my $counter = 1;
|
||||
my $hi = AE::timer 2, 0.25, sub {
|
||||
warn "Hi!\n";
|
||||
$quit->send if ++$counter > 4;
|
||||
};
|
||||
|
||||
my $hello = AE::timer 1, 0, sub {
|
||||
warn "Hello world!\n";
|
||||
};
|
||||
|
||||
$quit->recv;
|
||||
Loading…
Add table
Add a link
Reference in a new issue