NAME

Zing::Process - Processing Unit

ABSTRACT

Processing Unit and Actor Abstraction

SYNOPSIS

use Zing::Process;

my $process = Zing::Process->new;

# $process->execute;

DESCRIPTION

This package provides an actor abstraction which serve as a cooperative concurrent computational unit in an actor-model architecture.

LIBRARIES

This package uses type constraints from:

Zing::Types

ATTRIBUTES

This package has the following attributes:

cleanup

cleanup(Str)

This attribute is read-only, accepts (Str) values, and is optional.

data

data(Data)

This attribute is read-only, accepts (Data) values, and is optional.

journal

journal(Channel)

This attribute is read-only, accepts (Channel) values, and is optional.

log

log(Logger)

This attribute is read-only, accepts (Logger) values, and is optional.

logic

logic(Logic)

This attribute is read-only, accepts (Logic) values, and is optional.

loop

loop(Loop)

This attribute is read-only, accepts (Loop) values, and is optional.

mailbox

mailbox(Mailbox)

This attribute is read-only, accepts (Mailbox) values, and is optional.

meta

meta(Meta)

This attribute is read-only, accepts (Meta) values, and is optional.

name

name(Name)

This attribute is read-only, accepts (Name) values, and is optional.

parent

parent(Maybe[Process])

This attribute is read-only, accepts (Maybe[Process]) values, and is optional.

pid

pid(Int)

This attribute is read-only, accepts (Int) values, and is optional.

signals

signals(HashRef[Str|CodeRef])

This attribute is read-only, accepts (HashRef[Str|CodeRef]) values, and is optional.

started

started(Int)

This attribute is read-only, accepts (Int) values, and is optional.

stopped

stopped(Int)

This attribute is read-only, accepts (Int) values, and is optional.

tag

tag(Str)

This attribute is read-only, accepts (Str) values, and is optional.

METHODS

This package implements the following methods:

defer

defer(HashRef $data) : Object

The defer method allows a process to sends a message to itself for later processing.

defer example #1
# given: synopsis

$process->defer({ task => { launch => time } });

destroy

destroy() : Object

The destroy method de-registers the process and drops the process-specific data stores.

destroy example #1
# given: synopsis

$process->destroy;

execute

execute() : Object

The execute method executes the process event-loop indefinitely.

execute example #1
# given: synopsis

$process->execute;

exercise

exercise() : Object

The exercise method executes the event-loop but stops after one iteration.

exercise example #1
# given: synopsis

$process->exercise;

metadata

metadata() : HashRef

The metadata method returns metadata specific to the process.

metadata example #1
# given: synopsis

$process->metadata;

ping

ping(Int $pid) : Bool

The ping method returns truthy if the process of the PID provided is active.

ping example #1
# given: synopsis

$process->ping(12345);

recv

recv() : Maybe[HashRef]

The recv method is a proxy for "recv" in Zing::Mailbox and receives a single new message from the mailbox.

recv example #1
# given: synopsis

$process->recv;
recv example #2
# given: synopsis

my $peer = Zing::Process->new;

$peer->send($process, { note => 'ehlo' });

$process->recv;

reply

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.

reply example #1
# given: synopsis

my $peer = Zing::Process->new;

$peer->send($process, { note => 'ehlo' });

my $mail = $process->recv;

$process->reply($mail, { note => 'helo' });

send

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.

send example #1
# given: synopsis

my $peer = Zing::Process->new;

$process->send($peer, { note => 'invite' });
send example #2
# given: synopsis

my $peer = Zing::Process->new;

$process->send($peer->mailbox, { note => 'invite' });
send example #3
# given: synopsis

my $peer = Zing::Process->new;

$process->send($peer->mailbox->term, { note => 'invite' });

shutdown

shutdown() : Object

The shutdown method haults the process event-loop immediately.

shutdown example #1
# given: synopsis

$process->shutdown;

signal

signal(Int $pid, Str $type = 'kill') : Int

The signal method sends a kill signal to the process of the PID provided.

signal example #1
# given: synopsis

$process->signal(12345);
signal example #2
# given: synopsis

$process->signal(12345, 'term');

spawn

spawn(Scheme $scheme) : Fork

The spawn method forks a scheme and returns a Zing::Fork handler.

spawn example #1
# given: synopsis

$process->spawn(['MyApp', [], 1]);

term

term() : Str

The term method generates a term (safe string) for the datastore.

term example #1
# given: synopsis

$process->term;

winddown

winddown() : Object

The winddown method haults the process event-loop after the current iteration.

winddown example #1
# given: synopsis

$process->winddown;

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

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".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues