| 1 | package Zing::Single; | ||
| 2 | |||
| 3 | 8 | ▶ | use 5.014; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 8 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 8 | ▶ | use registry 'Zing::Types'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 8 | ▶ | use routines; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 8 | ▶ | use Data::Object::Class; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 8 | ▶ | use Zing::Logic::Single; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 8 | extends 'Zing::Process'; | |
| 16 | |||
| 17 | 8 | our $VERSION = '0.26'; # VERSION | |
| 18 | |||
| 19 | # BUILDERS | ||
| 20 | |||
| 21 | 0 | ▶ | fun new_logic($self) { |
|
Subroutine
new_logic: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 22 | 0 | my $debug = $self->env->debug; | |
| 23 | 0 | Zing::Logic::Single->new(debug => $debug, process => $self) | |
| 24 | 8 | } | |
| 25 | |||
| 26 | 8 | 1; | |
| 27 | |||
| 28 | =encoding utf8 | ||
| 29 | |||
| 30 | =head1 NAME | ||
| 31 | |||
| 32 | Zing::Single - Single Process | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | =head1 ABSTRACT | ||
| 37 | |||
| 38 | Single Process | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | =head1 SYNOPSIS | ||
| 43 | |||
| 44 | package MyApp; | ||
| 45 | |||
| 46 | use parent 'Zing::Single'; | ||
| 47 | |||
| 48 | sub perform { | ||
| 49 | my ($self) = @_; | ||
| 50 | |||
| 51 | time; | ||
| 52 | } | ||
| 53 | |||
| 54 | sub receive { | ||
| 55 | my ($self, $from, $data) = @_; | ||
| 56 | |||
| 57 | [$from, $data]; | ||
| 58 | } | ||
| 59 | |||
| 60 | package main; | ||
| 61 | |||
| 62 | my $myapp = MyApp->new; | ||
| 63 | |||
| 64 | # $myapp->execute; | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | =head1 DESCRIPTION | ||
| 69 | |||
| 70 | This package provides a L<Zing::Process> which runs once and shuts-down, but | ||
| 71 | otherwise operates as a typical process and invokes its C<receive> and | ||
| 72 | C<perform> methods. | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | =head1 INHERITS | ||
| 77 | |||
| 78 | This package inherits behaviors from: | ||
| 79 | |||
| 80 | L<Zing::Process> | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||
| 84 | =head1 LIBRARIES | ||
| 85 | |||
| 86 | This package uses type constraints from: | ||
| 87 | |||
| 88 | L<Zing::Types> | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | =head1 SCENARIOS | ||
| 93 | |||
| 94 | This package supports the following scenarios: | ||
| 95 | |||
| 96 | =cut | ||
| 97 | |||
| 98 | =head2 perform | ||
| 99 | |||
| 100 | # given: synopsis | ||
| 101 | |||
| 102 | $myapp->perform; | ||
| 103 | |||
| 104 | The perform method is meant to be implemented by a subclass and is | ||
| 105 | automatically invoked iteratively by the event-loop. | ||
| 106 | |||
| 107 | =cut | ||
| 108 | |||
| 109 | =head2 receive | ||
| 110 | |||
| 111 | # given: synopsis | ||
| 112 | |||
| 113 | $myapp->receive($myapp->name, { task => 'fuzzy_logic' }); | ||
| 114 | |||
| 115 | The receive method is meant to be implemented by a subclass and is | ||
| 116 | automatically invoked iteratively by the event-loop whenever a process receives | ||
| 117 | a message in its mailbox. | ||
| 118 | |||
| 119 | =cut | ||
| 120 | |||
| 121 | =head1 AUTHOR | ||
| 122 | |||
| 123 | Al Newkirk, C<awncorp@cpan.org> | ||
| 124 | |||
| 125 | =head1 LICENSE | ||
| 126 | |||
| 127 | Copyright (C) 2011-2019, Al Newkirk, et al. | ||
| 128 | |||
| 129 | This is free software; you can redistribute it and/or modify it under the terms | ||
| 130 | of the The Apache License, Version 2.0, as elucidated in the L<"license | ||
| 131 | file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>. | ||
| 132 | |||
| 133 | =head1 PROJECT | ||
| 134 | |||
| 135 | L<Wiki|https://github.com/iamalnewkirk/zing/wiki> | ||
| 136 | |||
| 137 | L<Project|https://github.com/iamalnewkirk/zing> | ||
| 138 | |||
| 139 | L<Initiatives|https://github.com/iamalnewkirk/zing/projects> | ||
| 140 | |||
| 141 | L<Milestones|https://github.com/iamalnewkirk/zing/milestones> | ||
| 142 | |||
| 143 | L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md> | ||
| 144 | |||
| 145 | L<Issues|https://github.com/iamalnewkirk/zing/issues> | ||
| 146 | |||
| 147 | =cut | ||