1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
9
<holder>Ericsson AB, All Rights Reserved</holder>
12
The contents of this file are subject to the Erlang Public License,
13
Version 1.1, (the "License"); you may not use this file except in
14
compliance with the License. You should have received a copy of the
15
Erlang Public License along with this software. If not, it can be
16
retrieved online at http://www.erlang.org/.
18
Software distributed under the License is distributed on an "AS IS"
19
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
20
the License for the specific language governing rights and limitations
23
The Initial Developer of the Original Code is Ericsson AB.
33
<modulesummary>Distributed, Named Process Groups</modulesummary>
35
<p>This (experimental) module implements process groups. A process
36
group is a group of processes that can be accessed by a common
37
name. For example, a group named <c>foobar</c> can include a set
38
of processes as members of this group and they can be located on
40
<p>When messages are sent to the named group, all members of
41
the group receive the message. The messages are serialized. If
42
the process <c>P1</c> sends the message <c>M1</c> to the group,
43
and process <c>P2</c> simultaneously sends message <c>M2</c>, then
44
all members of the group receive the two messages in the same
45
order. If members of a group terminate, they are automatically
46
removed from the group.</p>
47
<p>This module is not complete. The module is inspired by the ISIS
48
system and the causal order protocol of the ISIS system should
49
also be implemented. At the moment, all messages are serialized
50
by sending them through a group master process.</p>
54
<name>create(PgName) -> ok | {error, Reason}</name>
55
<fsummary>Create an empty group</fsummary>
57
<v>PgName = term()</v>
58
<v>Reason = already_created | term()</v>
61
<p>Creates an empty group named <c>PgName</c> on the current
66
<name>create(PgName, Node) -> ok | {error, Reason}</name>
67
<fsummary>Create an empty group on another node</fsummary>
69
<v>PgName = term()</v>
71
<v>Reason = already_created | term()</v>
74
<p>Creates an empty group named <c>PgName</c> on the node
79
<name>join(PgName, Pid) -> Members</name>
80
<fsummary>Join a pid to a process group</fsummary>
82
<v>PgName = term()</v>
84
<v>Members = [pid()]</v>
87
<p>Joins the pid <c>Pid</c> to the process group <c>PgName</c>.
88
Returns a list of all old members of the group.</p>
92
<name>send(PgName, Msg) -> void()</name>
93
<fsummary>Send a message to all members of a process group</fsummary>
95
<v>PgName = Msg = term()</v>
98
<p>Sends the tuple <c>{pg_message, From, PgName, Msg}</c> to
99
all members of the process group <c>PgName</c>.</p>
100
<p>Failure: <c>{badarg, {PgName, Msg}}</c> if <c>PgName</c> is
101
not a process group (a globally registered name).</p>
105
<name>esend(PgName, Msg) -> void()</name>
106
<fsummary>Send a message to all members of a process group, except ourselves</fsummary>
108
<v>PgName = Msg = term()</v>
111
<p>Sends the tuple <c>{pg_message, From, PgName, Msg}</c> to
112
all members of the process group <c>PgName</c>, except
114
<p>Failure: <c>{badarg, {PgName, Msg}}</c> if <c>PgName</c> is
115
not a process group (a globally registered name).</p>
119
<name>members(PgName) -> Members</name>
120
<fsummary>Return a list of all members of a process group</fsummary>
122
<v>PgName = term()</v>
123
<v>Members = [pid()]</v>
126
<p>Returns a list of all members of the process group