-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockerTest
executable file
·54 lines (41 loc) · 1.15 KB
/
blockerTest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env perl
use EV; use AnyEvent;
use lib qw(.);
use Verbose;
use Data::Dumper;
use AnyEvent::Blocker;
our $Package = __PACKAGE__;
sub main {
my $nb = AnyEvent::Blocker->new(new => 'xNet::Bonjour',base=>4, sub { vverbose 0,"Made ".shift });
$nb->base( sub { vverbose 0, "base for $nb is ",@_});
$nb->f1(1,2, sub{ vverbose 0,"f1() finished with ".Dumper(\@_);} );
$nb->f2(3 , sub{ vverbose 0,"f2() finished with ".Dumper(\@_);} );
# my $w2 = AnyEvent::Blocker->new;
# $w2->something('warg1', a => 1, sub{ vverbose 0,"Something2() finished with ".Dumper(\@_);} );
foreach(0..(1000*1000*20)) { my $i=$_; }
my $aew = AnyEvent->timer (after => 4, cb => sub{ vverbose 0,"Timer!"});
print "wait, using $AnyEvent::MODEL\n";
EV::loop;
print "loop exited\n";
sleep 2;
print "Done\n";
}
package xNet::Bonjour;
use Moose;
use Verbose;
use Data::Dumper;
has base => ( is => 'rw', default => 5 );
sub f1 {
my $self=shift;
my ($a,$b) = @_;
vverbose 0,"Called: $self ",Dumper(\@_);
return $a+$b;
}
sub f2 {
my $self=shift;
my ($a) = @_;
vverbose 0,"Called: $self ",Dumper(\@_);
return $a+$self->base;
}
no Moose;
$Package->main;