summaryrefslogtreecommitdiff
path: root/lib/kernel/doc/src/pg2.xml
blob: 4a7a2d77b137e92772e79633a2f2d4d65e0ea90a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>1997</year><year>2016</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
 
          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    
    </legalnotice>

    <title>pg2</title>
    <prepared>mbj@erlang.ericsson.se</prepared>
    <responsible>mbj@erlang.ericsson.se</responsible>
    <docno></docno>
    <approved>Bjarne D&auml;cker</approved>
    <checked>mbj@erlang.ericsson.se</checked>
    <date>1997-08-18</date>
    <rev>A2</rev>
    <file>pg2.sgml</file>
  </header>
  <module>pg2</module>
  <modulesummary>Distributed Named Process Groups</modulesummary>
  <description>
    <p>This module implements process groups. Each message may be sent
      to one, some, or all members of the group.
      </p>
    <p>A group of processes can be accessed by a common name. For
      example, if there is a group named <c>foobar</c>, there can be a
      set of processes (which can be located on different nodes) which
      are all members of the group <c>foobar</c>. There are no special
      functions for sending a message to the group. Instead, client
      functions should be written with the functions
      <c>get_members/1</c> and <c>get_local_members/1</c> to find out
      which processes are members of the group. Then the message can be
      sent to one or more members of the group.
      </p>
    <p>If a member terminates, it is automatically removed from the
      group.
      </p>
    <warning>
      <p>This module is used by the <c>disk_log</c> module for
        managing distributed disk logs. The disk log names are used as
        group names, which means that some action may need to be taken
        to avoid name clashes.</p>
    </warning>
  </description>
  <datatypes>
    <datatype>
      <name name="name"/>
      <desc><p>The name of a process group.</p></desc>
    </datatype>
  </datatypes>
  <funcs>
    <func>
      <name name="create" arity="1"/>
      <fsummary>Create a new, empty process group</fsummary>
      <desc>
        <p>Creates a new, empty process group. The group is globally
          visible on all nodes. If the group exists, nothing happens.
          </p>
      </desc>
    </func>
    <func>
      <name name="delete" arity="1"/>
      <fsummary>Delete a process group</fsummary>
      <desc>
        <p>Deletes a process group.
          </p>
      </desc>
    </func>
    <func>
      <name name="get_closest_pid" arity="1"/>
      <fsummary>Common dispatch function</fsummary>
      <desc>
        <p>This is a useful dispatch function which can be used from
          client functions. It returns a process on the local node, if
          such a process exist. Otherwise, it chooses one randomly.
          </p>
      </desc>
    </func>
    <func>
      <name name="get_members" arity="1"/>
      <fsummary>Return all processes in a group</fsummary>
      <desc>
        <p>Returns all processes in the group <c>Name</c>. This
          function should be used from within a client function that
          accesses the group. It is therefore optimized for speed.
          </p>
      </desc>
    </func>
    <func>
      <name name="get_local_members" arity="1"/>
      <fsummary>Return all local processes in a group</fsummary>
      <desc>
        <p>Returns all processes running on the local node in the
          group <c>Name</c>. This function should to be used from
          within a client function that accesses the group. It is therefore
          optimized for speed.
          </p>
      </desc>
    </func>
    <func>
      <name name="join" arity="2"/>
      <fsummary>Join a process to a group</fsummary>
      <desc>
        <p>Joins the process <c>Pid</c> to the group <c>Name</c>.
	  A process can join a group several times; it must then
	  leave the group the same number of times.
          </p>
      </desc>
    </func>
    <func>
      <name name="leave" arity="2"/>
      <fsummary>Make a process leave a group</fsummary>
      <desc>
        <p>Makes the process <c>Pid</c> leave the group <c>Name</c>.
	  If the process is not a member of the group, <c>ok</c> is
	  returned.
          </p>
      </desc>
    </func>
    <func>
      <name name="which_groups" arity="0"/>
      <fsummary>Return a list of all known groups</fsummary>
      <desc>
        <p>Returns a list of all known groups.
          </p>
      </desc>
    </func>
    <func>
      <name name="start" arity="0"/>
      <name name="start_link" arity="0"/>
      <fsummary>Start the pg2 server</fsummary>
      <desc>
        <p>Starts the pg2 server. Normally, the server does not need
          to be started explicitly, as it is started dynamically if it
          is needed. This is useful during development, but in a
          target system the server should be started explicitly. Use
          configuration parameters for <c>kernel</c> for this.
          </p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>See Also</title>
    <p><seealso marker="kernel_app">kernel(6)</seealso></p>
  </section>
</erlref>