| 1 | package Zing::Logic; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 56 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 56 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 56 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 56 | ▶ | use registry 'Zing::Types'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 56 | ▶ | use routines; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 56 | ▶ | use Data::Object::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 56 | ▶ | use Data::Object::ClassHas; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 56 | ▶ | use Zing::Flow; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 56 | our $VERSION = '0.26'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 56 | has 'debug' => ( | |||||||||||||||||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | def => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 56 | has 'interupt' => ( | |||||||||||||||||||||||||||||||||||||||||
| 27 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 28 | isa => 'Interupt', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | opt => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 56 | has 'on_perform' => ( | |||||||||||||||||||||||||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => 'CodeRef', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | new => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | fun new_on_perform($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_on_perform: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->can('handle_perform_event') | |||||||||||||||||||||||||||||||||||||||||
| 40 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 56 | has 'on_receive' => ( | |||||||||||||||||||||||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | isa => 'CodeRef', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | new => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | fun new_on_receive($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_on_receive: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $self->can('handle_receive_event') | |||||||||||||||||||||||||||||||||||||||||
| 50 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 56 | has 'on_register' => ( | |||||||||||||||||||||||||||||||||||||||||
| 53 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | isa => 'CodeRef', | ||||||||||||||||||||||||||||||||||||||||||
| 55 | new => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | fun new_on_register($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_on_register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->can('handle_register_event') | |||||||||||||||||||||||||||||||||||||||||
| 60 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 56 | has 'on_reset' => ( | |||||||||||||||||||||||||||||||||||||||||
| 63 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | isa => 'CodeRef', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | new => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | fun new_on_reset($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_on_reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->can('handle_reset_event') | |||||||||||||||||||||||||||||||||||||||||
| 70 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 56 | has 'on_suicide' => ( | |||||||||||||||||||||||||||||||||||||||||
| 73 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 74 | isa => 'CodeRef', | ||||||||||||||||||||||||||||||||||||||||||
| 75 | new => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | fun new_on_suicide($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_on_suicide: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $self->can('handle_suicide_event') | |||||||||||||||||||||||||||||||||||||||||
| 80 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 56 | has 'process' => ( | |||||||||||||||||||||||||||||||||||||||||
| 83 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 84 | isa => 'Process', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | req => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # SHIMS | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | sub _kill { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | CORE::kill(shift, shift) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_kill: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | sub _repr { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | "$_[0]" =~ s/^((?:[\w:]+=*)\w+)\((\w+)\)/($1)/r | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_repr: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | sub _words { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | (map {ref() ? _repr($_) : m/\s+/ ? qq("$_") : $_} @_) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_words: not called CC=3 SCAR=24.8
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | # METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | method flow() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flow: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my $step_0 = Zing::Flow->new( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | name => 'on_register', | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | code => fun($step, $loop) { $self->trace('on_register')->($self) } | |||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $step_1 = $step_0->next(Zing::Flow->new( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | name => 'on_perform', | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | code => fun($step, $loop) { $self->trace('on_perform')->($self) } | |||||||||||||||||||||||||||||||||||||||||
| 112 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $step_2 = $step_1->next(Zing::Flow->new( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | name => 'on_receive', | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | code => fun($step, $loop) { $self->trace('on_receive')->($self) } | |||||||||||||||||||||||||||||||||||||||||
| 116 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $step_3 = $step_2->next(Zing::Flow->new( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | name => 'on_reset', | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | code => fun($step, $loop) { $self->trace('on_reset')->($self) } | |||||||||||||||||||||||||||||||||||||||||
| 120 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $step_4 = $step_3->next(Zing::Flow->new( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | name => 'on_suicide', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | code => fun($step, $loop) { $self->trace('on_suicide')->($self) } | |||||||||||||||||||||||||||||||||||||||||
| 124 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $step_0 | |||||||||||||||||||||||||||||||||||||||||
| 127 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | method note(Any @data) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ($self->debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->process->log->debug( | |||||||||||||||||||||||||||||||||||||||||
| 132 | join ' ', sprintf('in %s, %s', _words($self, $self->process)), @data | ||||||||||||||||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | method handle_perform_event() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_perform_event: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $process = $self->process; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return $self if !$process->can('perform'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $process->perform(); | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | method handle_receive_event() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_receive_event: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $process = $self->process; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | return $self if !$process->can('mailbox'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | return $self if !$process->can('receive'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | my $data = $process->mailbox->recv or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $process->receive($data->{from}, $data->{data}); | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | method handle_register_event() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_register_event: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $process = $self->process; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | return $self if $self->{registered}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->{registered} = $process->meta->send($process->metadata); | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | method handle_reset_event() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_reset_event: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $process = $self->process; | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($process->journal && $process->log->count && $process->env->debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$process->journal and $process->log->count and $process->env->debug
$process->journal and $process->log->count
MC/DC0%0/3
$process->journal and $process->log->count and $process->env->debug
$process->journal
$process->log->count
$process->env->debug
Truth table0%0/4
A and B and C
A= $process->journalB= $process->log->countC= $process->env->debug
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $process->journal->send({ | |||||||||||||||||||||||||||||||||||||||||
| 176 | from => $process->name, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | data => { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | logs => $process->log->serialize, | ||||||||||||||||||||||||||||||||||||||||||
| 179 | tag => $process->tag | ||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $process->log->reset; | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | method handle_suicide_event() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_suicide_event: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $process = $self->process; | |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return $self if !$process->parent; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # children who don't known their parents kill themeselves :) | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | $process->winddown unless $process->ping($process->parent->pid); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | method signals() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signals: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $trapped = {}; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | $trapped->{INT} = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $self->trace('interupt', 'INT'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $self->process->winddown; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | $trapped->{QUIT} = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $self->trace('interupt', 'QUIT'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $self->process->winddown; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | $trapped->{TERM} = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $self->trace('interupt', 'TERM'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->process->winddown; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return $trapped; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | method trace(Str $method, Any @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trace: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | my @with = (@args ? (join ', ', 'with', _words(@args)) : ()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return $self->note(qq(invokes "$method"), @with)->$method(@args); | |||||||||||||||||||||||||||||||||||||||||
| 225 | 56 | } | |||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 56 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | Zing::Logic - Process Logic | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =head1 ABSTRACT | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | Process Logic Chain | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | use Zing::Logic; | ||||||||||||||||||||||||||||||||||||||||||
| 246 | use Zing::Process; | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | my $process = Zing::Process->new; | ||||||||||||||||||||||||||||||||||||||||||
| 249 | my $logic = Zing::Logic->new(process => $process); | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | This package provides the logic (or logic chain) to be executed by the process | ||||||||||||||||||||||||||||||||||||||||||
| 256 | event-loop. | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | =head1 LIBRARIES | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | This package uses type constraints from: | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | L<Zing::Types> | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | This package has the following attributes: | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | =head2 interupt | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | interupt(Interupt) | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | This attribute is read-only, accepts C<(Interupt)> values, and is optional. | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | =head2 on_perform | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | on_perform(CodeRef) | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | =head2 on_receive | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | on_receive(CodeRef) | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | =head2 on_register | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | on_register(CodeRef) | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | =head2 on_reset | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | on_reset(CodeRef) | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | =head2 on_suicide | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | on_suicide(CodeRef) | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | =head2 process | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | process(Process) | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | This attribute is read-only, accepts C<(Process)> values, and is required. | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | This package implements the following methods: | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | =head2 flow | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | flow() : Flow | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | The flow method builds and returns the logic flow for the process event-loop. | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | =item flow example #1 | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | my $flow = $logic->flow; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | =head2 signals | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | signals() : HashRef | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | The signals method builds and returns the process signal handlers. | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | =item signals example #1 | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | my $signals = $logic->signals; | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | Al Newkirk, C<awncorp@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | Copyright (C) 2011-2019, Al Newkirk, et al. | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | This is free software; you can redistribute it and/or modify it under the terms | ||||||||||||||||||||||||||||||||||||||||||
| 381 | of the The Apache License, Version 2.0, as elucidated in the L<"license | ||||||||||||||||||||||||||||||||||||||||||
| 382 | file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>. | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | =head1 PROJECT | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | L<Wiki|https://github.com/iamalnewkirk/zing/wiki> | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | L<Project|https://github.com/iamalnewkirk/zing> | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | L<Initiatives|https://github.com/iamalnewkirk/zing/projects> | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | L<Milestones|https://github.com/iamalnewkirk/zing/milestones> | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md> | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | L<Issues|https://github.com/iamalnewkirk/zing/issues> | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | =cut | ||||||||||||||||||||||||||||||||||||||||||