Zing::Process - Processing Unit
Processing Unit and Actor Abstraction
use Zing::Process; my $process = Zing::Process->new; # $process->execute;
This package provides an actor abstraction which serve as a cooperative concurrent computational unit in an actor-model architecture.
This package uses type constraints from:
Zing::Types
This package has the following attributes:
cleanup(Str)
This attribute is read-only, accepts (Str) values, and is optional.
(Str)
data(Data)
This attribute is read-only, accepts (Data) values, and is optional.
(Data)
journal(Channel)
This attribute is read-only, accepts (Channel) values, and is optional.
(Channel)
log(Logger)
This attribute is read-only, accepts (Logger) values, and is optional.
(Logger)
logic(Logic)
This attribute is read-only, accepts (Logic) values, and is optional.
(Logic)
loop(Loop)
This attribute is read-only, accepts (Loop) values, and is optional.
(Loop)
mailbox(Mailbox)
This attribute is read-only, accepts (Mailbox) values, and is optional.
(Mailbox)
meta(Meta)
This attribute is read-only, accepts (Meta) values, and is optional.
(Meta)
name(Name)
This attribute is read-only, accepts (Name) values, and is optional.
(Name)
on_perform(Maybe[CodeRef])
This attribute is read-only, accepts (Maybe[CodeRef]) values, and is optional.
(Maybe[CodeRef])
on_receive(Maybe[CodeRef])
parent(Maybe[Process])
This attribute is read-only, accepts (Maybe[Process]) values, and is optional.
(Maybe[Process])
pid(Int)
This attribute is read-only, accepts (Int) values, and is optional.
(Int)
signals(HashRef[Str|CodeRef])
This attribute is read-only, accepts (HashRef[Str|CodeRef]) values, and is optional.
(HashRef[Str|CodeRef])
started(Int)
stopped(Int)
tag(Str)
This package implements the following methods:
defer(HashRef $data) : Object
The defer method allows a process to sends a message to itself for later processing.
# given: synopsis $process->defer({ task => { launch => time } });
destroy() : Object
The destroy method de-registers the process and drops the process-specific data stores.
# given: synopsis $process->destroy;
execute() : Object
The execute method executes the process event-loop indefinitely.
# given: synopsis $process->execute;
exercise() : Object
The exercise method executes the event-loop but stops after one iteration.
# given: synopsis $process->exercise;
metadata() : HashRef
The metadata method returns metadata specific to the process.
# given: synopsis $process->metadata;
ping(Int $pid) : Bool
The ping method returns truthy if the process of the PID provided is active.
# given: synopsis $process->ping(12345);
receive(Str $from, HashRef $data) : Any
The receive method, when not overloaded, executes the callback in the "on_receive" attribute for each cycle of the event loop.
# given: synopsis $process = Zing::Process->new( on_receive => sub { my ($self, $from, $data) = @_; [$from, $data]; }, ); $process->receive($process->term, { ping => 1 });
recv() : Maybe[HashRef]
The recv method is a proxy for "recv" in Zing::Mailbox and receives a single new message from the mailbox.
# given: synopsis $process->recv;
# given: synopsis my $peer = Zing::Process->new; $peer->send($process, { note => 'ehlo' }); $process->recv;
reply(HashRef $bag, HashRef $value) : Int
The reply method is a proxy for "reply" in Zing::Mailbox and sends a message to the mailbox represented by the $bag received.
$bag
# given: synopsis my $peer = Zing::Process->new; $peer->send($process, { note => 'ehlo' }); my $mail = $process->recv; $process->reply($mail, { note => 'helo' });
send(Mailbox | Process | Str $to, HashRef $data) : Int
The send method is a proxy for "send" in Zing::Mailbox and sends a new message to the mailbox specified.
# given: synopsis my $peer = Zing::Process->new; $process->send($peer, { note => 'invite' });
# given: synopsis my $peer = Zing::Process->new; $process->send($peer->mailbox, { note => 'invite' });
# given: synopsis my $peer = Zing::Process->new; $process->send($peer->mailbox->term, { note => 'invite' });
shutdown() : Object
The shutdown method haults the process event-loop immediately.
# given: synopsis $process->shutdown;
signal(Int $pid, Str $type = 'kill') : Int
The signal method sends a kill signal to the process of the PID provided.
kill
# given: synopsis $process->signal(12345);
# given: synopsis $process->signal(12345, 'term');
spawn(Scheme $scheme) : Fork
The spawn method forks a scheme and returns a Zing::Fork handler.
# given: synopsis $process->spawn(['MyApp', [], 1]);
term() : Str
The term method generates a term (safe string) for the datastore.
# given: synopsis $process->term;
winddown() : Object
The winddown method haults the process event-loop after the current iteration.
# given: synopsis $process->winddown;
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Zing, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Zing
CPAN shell
perl -MCPAN -e shell install Zing
For more information on module installation, please visit the detailed CPAN module installation guide.