line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cassandra::Client::Util; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TVDW'; |
3
|
|
|
|
|
|
|
$Cassandra::Client::Util::VERSION = '0.13_004'; # TRIAL |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
17
|
$Cassandra::Client::Util::VERSION = '0.13004';use 5.010; |
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
10
|
|
|
|
|
|
|
our @EXPORT= ('series', 'parallel', 'whilst'); |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
290
|
use Sub::Current; |
|
1
|
|
|
|
|
222
|
|
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub series { |
15
|
0
|
|
|
0
|
0
|
|
my $list= shift; |
16
|
0
|
|
|
|
|
|
my $final= shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
(shift @$list)->(sub { |
19
|
0
|
|
|
0
|
|
|
my $next= shift @$list; |
20
|
0
|
0
|
0
|
|
|
|
if ($next && !$_[0]) { |
21
|
0
|
|
|
|
|
|
splice @_, 0, 1, ROUTINE(); |
22
|
0
|
|
|
|
|
|
goto &$next; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
goto &$final; |
26
|
0
|
|
|
|
|
|
}); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub parallel { |
32
|
0
|
|
|
0
|
0
|
|
my ($list, $final)= @_; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if (!@$list) { |
35
|
0
|
|
|
|
|
|
return $final->(); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $remaining= 0+@$list; |
39
|
0
|
|
|
|
|
|
my @result; |
40
|
0
|
|
|
|
|
|
for my $i (0..$#$list) { |
41
|
|
|
|
|
|
|
$list->[$i]->(sub { |
42
|
0
|
|
|
0
|
|
|
my ($error, $result)= @_; |
43
|
0
|
0
|
|
|
|
|
if ($error) { |
44
|
0
|
0
|
|
|
|
|
if ($remaining > 0) { |
45
|
0
|
|
|
|
|
|
$remaining= 0; |
46
|
0
|
|
|
|
|
|
$final->($error); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$result[$i]= $result; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$remaining--; |
54
|
0
|
0
|
|
|
|
|
if ($remaining == 0) { |
55
|
0
|
|
|
|
|
|
$final->(undef, @result); |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
}); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub whilst { |
64
|
0
|
|
|
0
|
0
|
|
my ($condition, $iteratee, $callback)= @_; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
(sub { |
67
|
0
|
0
|
0
|
0
|
|
|
if (defined $_[0] || !($condition->())) { |
68
|
0
|
|
|
|
|
|
goto &$callback; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
splice @_, 0, 1, ROUTINE(); |
71
|
0
|
|
|
|
|
|
goto &$iteratee; |
72
|
0
|
|
|
|
|
|
})->(); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |