NAME

Zing::Mailbox - Process Mailbox

ABSTRACT

Interprocess Communication Mechanism

SYNOPSIS

use Zing::Mailbox;
use Zing::Process;

my $mailbox = Zing::Mailbox->new(process => Zing::Process->new);

# $mailbox->recv;

DESCRIPTION

This package provides represents a process mailbox, the default mechanism of interprocess communication.

INHERITS

This package inherits behaviors from:

Zing::PubSub

LIBRARIES

This package uses type constraints from:

Zing::Types

ATTRIBUTES

This package has the following attributes:

name

name(Str)

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

process

process(Process)

This attribute is read-only, accepts (Process) values, and is required.

METHODS

This package implements the following methods:

recv

recv() : Maybe[HashRef]

The recv method receives a single new message from the mailbox.

recv example #1
# given: synopsis

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

$mailbox->send($mailbox->process->name, { status => 'hello' });

$mailbox->recv;

reply

reply(HashRef $bag, HashRef $value) : Int

The reply method sends a message to the mailbox represented by the $data received and returns the size of the recipient mailbox.

reply example #1
# given: synopsis

$mailbox->send($mailbox->process->name, { status => 'hello' });

my $data = $mailbox->recv;

$mailbox->reply($data, { status => 'thank you' });

send

send(Str $key, HashRef $value) : Int

The send method sends a new message to the mailbox specified and returns the size of the recipient mailbox.

send example #1
# given: synopsis

$mailbox->send($mailbox->process->name, { status => 'hello' });

size

size() : Int

The size method returns the message count of the mailbox.

size example #1
# given: synopsis

my $size = $mailbox->size;

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