line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Evo::Lib; |
2
|
8
|
|
|
8
|
|
3002
|
use Evo '-Export *; Carp croak; Evo::Lib::PP * -try'; # only have try in XS |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
46
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
export_proxy 'Evo::Lib::PP', '*', '-try'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $IMPL = eval { require Evo::Lib::XS; 1 } ? 'Evo::Lib::XS' : 'Evo::Lib::PP'; |
7
|
|
|
|
|
|
|
$IMPL->import('try'); |
8
|
|
|
|
|
|
|
export('try'); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# marked as deprecated 24.09.2016 |
12
|
|
|
|
|
|
|
#use Time::HiRes qw(CLOCK_MONOTONIC); |
13
|
|
|
|
|
|
|
#my $HAS_M_TIME = eval { Time::HiRes::clock_gettime(CLOCK_MONOTONIC); 1; }; |
14
|
|
|
|
|
|
|
#export_code steady_time => $HAS_M_TIME |
15
|
|
|
|
|
|
|
# ? sub { Time::HiRes::clock_gettime(CLOCK_MONOTONIC); } |
16
|
|
|
|
|
|
|
# : sub { Time::HiRes::time() }; |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# marked as not useful at 24.09.2016 |
20
|
|
|
|
|
|
|
# combine higher order function without any protection and passing arguments |
21
|
|
|
|
|
|
|
#sub ws_fn : Export { |
22
|
|
|
|
|
|
|
# my $cb = pop or croak "Provide a function"; |
23
|
|
|
|
|
|
|
# return $cb unless @_; |
24
|
|
|
|
|
|
|
# $cb = $_->($cb) for reverse @_; |
25
|
|
|
|
|
|
|
# $cb; |
26
|
|
|
|
|
|
|
#} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# marked as not useful at 24.09.2016 |
29
|
|
|
|
|
|
|
# call each $next exactly once or die. Bypas args to cb |
30
|
|
|
|
|
|
|
#sub combine_thunks : Export { |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# my $_cb = pop or croak "Provide a function"; |
33
|
|
|
|
|
|
|
# return $_cb unless my @hooks = @_; |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# my @args; |
36
|
|
|
|
|
|
|
# my $cb = sub { $_cb->(@args) }; |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# foreach my $cur (reverse @hooks) { |
39
|
|
|
|
|
|
|
# my $last = $cb; |
40
|
|
|
|
|
|
|
# my $count = 0; |
41
|
|
|
|
|
|
|
# my $safe = sub { $last->() unless $count++ }; |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
# $cb = sub { $cur->($safe); die "\$next in hook called $count times" unless $count == 1 }; |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# } |
46
|
|
|
|
|
|
|
# |
47
|
|
|
|
|
|
|
# sub { @args = @_; $cb->(); return }; |
48
|
|
|
|
|
|
|
#} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |