1pg2(3)                     Erlang Module Definition                     pg2(3)
2
3
4

NAME

6       pg2 - Distributed named process groups.
7

DESCRIPTION

9   Warning:
10       The  pg2 module is deprecated as of OTP 23 and scheduled for removal in
11       OTP 24. You are advised to replace the usage of pg2 with pg. pg  has  a
12       similar  API, but with an implementation that is more scalable. See the
13       documentation of pg for more information about differences.
14
15
16       This module implements process groups. Each message can be sent to one,
17       some, or all group members.
18
19       A  group of processes can be accessed by a common name. For example, if
20       there is a group named foobar, there can be a set of  processes  (which
21       can  be  located  on different nodes) that are all members of the group
22       foobar. There are no special functions for sending  a  message  to  the
23       group.  Instead,  client functions are to be written with the functions
24       get_members/1 and get_local_members/1 to determine which processes  are
25       members of the group. Then the message can be sent to one or more group
26       members.
27
28       If a member terminates, it is automatically removed from the group.
29
30   Warning:
31       This module is used by module disk_log for  managing  distributed  disk
32       logs. The disk log names are used as group names, which means that some
33       action can be needed to avoid name clashes.
34
35

DATA TYPES

37       name() = any()
38
39              The name of a process group.
40

EXPORTS

42       create(Name :: name()) -> ok
43
44              Creates a new, empty process group. The group is globally  visi‐
45              ble on all nodes. If the group exists, nothing happens.
46
47       delete(Name :: name()) -> ok
48
49              Deletes a process group.
50
51       get_closest_pid(Name) -> pid() | {error, Reason}
52
53              Types:
54
55                 Name = name()
56                 Reason = {no_process, Name} | {no_such_group, Name}
57
58              A  useful  dispatch  function that can be used from client func‐
59              tions. It returns a process on the local node, if such a process
60              exists. Otherwise, it selects one randomly.
61
62       get_local_members(Name) ->
63                            [pid()] | {error, {no_such_group, Name}}
64
65              Types:
66
67                 Name = name()
68
69              Returns  all  processes  running  on the local node in the group
70              Name. This function is to be used from within a client  function
71              that accesses the group. It is therefore optimized for speed.
72
73       get_members(Name) -> [pid()] | {error, {no_such_group, Name}}
74
75              Types:
76
77                 Name = name()
78
79              Returns  all processes in the group Name. This function is to be
80              used from within a client function that accesses the  group.  It
81              is therefore optimized for speed.
82
83       join(Name, Pid :: pid()) -> ok | {error, {no_such_group, Name}}
84
85              Types:
86
87                 Name = name()
88
89              Joins  the  process  Pid to the group Name. A process can join a
90              group many times and must then leave the group the  same  number
91              of times.
92
93       leave(Name, Pid :: pid()) -> ok | {error, {no_such_group, Name}}
94
95              Types:
96
97                 Name = name()
98
99              Makes  the  process  Pid leave the group Name. If the process is
100              not a member of the group, ok is returned.
101
102       start() -> {ok, pid()} | {error, any()}
103
104       start_link() -> {ok, pid()} | {error, any()}
105
106              Starts the pg2 server. Normally, the server does not need to  be
107              started  explicitly,  as  it  is  started  dynamically  if it is
108              needed. This is useful during development, but in a target  sys‐
109              tem  the  server is to be started explicitly. Use the configura‐
110              tion parameters for kernel(6) for this.
111
112       which_groups() -> [Name :: name()]
113
114              Returns a list of all known groups.
115

SEE ALSO

117       kernel(6)
118
119
120
121Ericsson AB                       kernel 7.3                            pg2(3)
Impressum