The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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(Str)

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

journal

  journal(Str)

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

log

  log(Str)

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

logic

  logic(Str)

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

loop

  loop(Str)

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

mailbox

  mailbox(Str)

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

name

  name(Str)

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

node

  node(Str)

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

parent

  parent(Str)

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

registry

  registry(Str)

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

server

  server(Str)

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

signals

  signals(Str)

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

started

  started(Str)

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

stopped

  stopped(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