ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/AnyEvent-Fork-Pool/t/01_basic.t
Revision: 1.1
Committed: Sun Apr 21 12:04:32 2013 UTC (13 years, 5 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_1, rel-0_1
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 $| = 1;
2     print "1..63\n";
3    
4     use AnyEvent;
5     use AnyEvent::Fork::Pool;
6    
7     print "ok 1\n";
8    
9     # all parameters with default values
10     my $pool = AnyEvent::Fork
11     ->new
12     ->eval (do { local $/; <DATA> })
13     ->AnyEvent::Fork::Pool::run (
14     "run", # the worker function
15    
16     on_destroy => (my $finish = AE::cv), # called when object is destroyed
17     );
18    
19     print "ok 2\n";
20    
21     for (1..30) {
22     $pool->(doit => $_, sub {
23     print "ok # return\n";
24     });
25     }
26    
27     undef $pool;
28    
29     $finish->recv;
30    
31     print "ok 63\n";
32    
33     __DATA__
34    
35     sub run {
36     print "ok # run\n";
37     select undef, undef, undef, rand 0.2;
38     AnyEvent::Fork::Pool::retire() if rand > 0.5;
39     1
40     }
41