Branch Coverage

blib/lib/Sub/Throttler.pm
Criterion Covered Total %
branch 85 96 88.5


line true false branch
25 21 20 if (ref $cb_or_obj_or_class eq 'CODE') { }
14 6 elsif (&blessed($cb_or_obj_or_class)) { }
6 0 elsif (defined $cb_or_obj_or_class and not ref $cb_or_obj_or_class) { }
33 0 14 if not $method or ref $method and ref $method ne 'CODE'
35 13 1 if $obj
40 0 6 if not $method or ref $method and ref $method ne 'CODE'
51 4 107 if 2 != @_
52 3 104 unless ref $throttle
53 20 84 if ref $target ne 'CODE'
60 4 28 if $throttle
66 75 285 if ($IN_flush)
67 46 29 unless ($IN_flush_ignore_recursion)
85 2 195 unless (defined $this)
93 9 196 unless defined $resources
94 5 191 if ref $resources ne 'HASH'
96 1 190 unless keys %{$resources;}
99 4 195 if ref $quantity
101 96 92 if ($throttle->try_acquire($id, $key, $quantity)) { }
108 87 92 if ($acquired == keys %{$resources;}) { }
113 2 90 if ($acquired)
131 33 236 if $IN_flush_recursion
160 0 64 unless defined &{$func;}
163 14 50 if ($is_method) { }
182 13 73 unless defined $resources
183 5 68 if ref $resources ne 'HASH'
185 1 67 unless keys %{$resources;}
187 4 71 if ref $quantity
189 45 19 if ($throttle->try_acquire($id, $key, $quantity)) { }
202 8 11 if ($failed) { }
219 8 40 if ($failed) { }
230 90 15 if ($is_used) { }
236 24 103 if ($IN_flush_pending)
244 0 5 if not $func or ref $func
245 3 2 unless ($func =~ /::/ms)
248 0 5 unless defined &{$func;}
252 1 4 $is_asap ? :
0 5 unless eval 'sub ' . $func . " {\n if (!" . $is_sync . qq[ && \@_ && ref \$_[-1] eq "CODE") {\n my \$done = &throttle_me] . ($is_asap ? '_asap' : '') . " || return;\n my \$cb = pop;\n \$orig->(\@_, done_cb(\$done, \$cb));\n return;\n } elsif (wantarray) {\n my \$done = &throttle_me_sync;\n my \@res = &\$orig;\n \$done->();\n return \@res;\n } else {\n my \$done = &throttle_me_sync;\n my \$res = &\$orig;\n \$done->();\n return \$res;\n }\n }; 1"
32 14 if (@_ and ref $_[-1] eq 'CODE') { }
0 14 elsif (wantarray) { }
10 0 if (@_ and ref $_[-1] eq 'CODE') { }
0 0 elsif (wantarray) { }
276 87 245 if (ref $args->[$_] eq 'Sub::Throttler::__done')
281 2 105 unless defined &{$func;}
285 34 71 if ($is_method) { }
289 28 6 if (ref $self)
313 31 56 if ($this) { }
333 2 127 if ($Check{$id})
348 42 112 unless (delete $Check{$id})