line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# DESCRIPTION: Splice flow |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, |
6
|
|
|
|
|
|
|
#=============================================================================== |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Flow::Splice - Stream breakdown on a parts |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $f1 = Flow::create_flow( |
15
|
|
|
|
|
|
|
Splice => 200 ); |
16
|
|
|
|
|
|
|
$f1->run( 1, 3, 11 ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Flow::Splice; |
21
|
8
|
|
|
8
|
|
37
|
use warnings; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
257
|
|
22
|
8
|
|
|
8
|
|
37
|
use strict; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
253
|
|
23
|
8
|
|
|
8
|
|
3742
|
use Data::Dumper; |
|
8
|
|
|
|
|
45763
|
|
|
8
|
|
|
|
|
642
|
|
24
|
8
|
|
|
8
|
|
58
|
use Flow; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
246
|
|
25
|
8
|
|
|
8
|
|
50
|
use base 'Flow'; |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
3156
|
|
26
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
31
|
0
|
|
|
|
|
|
my $count = shift; |
32
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
33
|
0
|
|
|
|
|
|
$self->{stack} = []; |
34
|
0
|
|
|
|
|
|
$self->{_Splice} = $count; |
35
|
0
|
|
|
|
|
|
return $self; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub purge_stack { |
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
my $stack = $self->{stack}; |
42
|
0
|
|
|
|
|
|
my $res; |
43
|
0
|
0
|
|
|
|
|
if ( scalar(@$stack) ) { |
44
|
0
|
|
|
|
|
|
$res = $self->put_flow(@$stack); |
45
|
0
|
|
|
|
|
|
@$stack = (); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
$res #return put_flow res |
48
|
0
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub ctl_flow { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my $state = $self->purge_stack(); |
53
|
0
|
|
0
|
|
|
|
return $state || $self->SUPER::ctl_flow(@_); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub flow { |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
my $stack = $self->{stack}; |
59
|
0
|
|
|
|
|
|
my $count = $self->{_Splice}; |
60
|
0
|
|
|
|
|
|
foreach my $r (@_) { |
61
|
0
|
0
|
|
|
|
|
if ( @$stack >= $count ) { |
62
|
0
|
0
|
|
|
|
|
if ( my $status = $self->purge_stack() ) { return $status } |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
|
push @$stack, $r; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
return undef; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub end { |
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
71
|
0
|
|
|
|
|
|
my $stack = $self->{stack}; |
72
|
0
|
0
|
|
|
|
|
if ( my $status = $self->purge_stack() ) { return $status } |
|
0
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return \@_; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |