1pg2(3) Erlang Module Definition pg2(3)
2
3
4
6 pg2 - Distributed named process groups.
7
9 This module implements process groups. Each message can be sent to one,
10 some, or all group members.
11
12 A group of processes can be accessed by a common name. For example, if
13 there is a group named foobar, there can be a set of processes (which
14 can be located on different nodes) that are all members of the group
15 foobar. There are no special functions for sending a message to the
16 group. Instead, client functions are to be written with the functions
17 get_members/1 and get_local_members/1 to determine which processes are
18 members of the group. Then the message can be sent to one or more group
19 members.
20
21 If a member terminates, it is automatically removed from the group.
22
23 Warning:
24 This module is used by module disk_log for managing distributed disk
25 logs. The disk log names are used as group names, which means that some
26 action can be needed to avoid name clashes.
27
28
30 name() = any()
31
32 The name of a process group.
33
35 create(Name :: name()) -> ok
36
37 Creates a new, empty process group. The group is globally visi‐
38 ble on all nodes. If the group exists, nothing happens.
39
40 delete(Name :: name()) -> ok
41
42 Deletes a process group.
43
44 get_closest_pid(Name) -> pid() | {error, Reason}
45
46 Types:
47
48 Name = name()
49 Reason = {no_process, Name} | {no_such_group, Name}
50
51 A useful dispatch function that can be used from client func‐
52 tions. It returns a process on the local node, if such a process
53 exists. Otherwise, it selects one randomly.
54
55 get_local_members(Name) ->
56 [pid()] | {error, {no_such_group, Name}}
57
58 Types:
59
60 Name = name()
61
62 Returns all processes running on the local node in the group
63 Name. This function is to be used from within a client function
64 that accesses the group. It is therefore optimized for speed.
65
66 get_members(Name) -> [pid()] | {error, {no_such_group, Name}}
67
68 Types:
69
70 Name = name()
71
72 Returns all processes in the group Name. This function is to be
73 used from within a client function that accesses the group. It
74 is therefore optimized for speed.
75
76 join(Name, Pid :: pid()) -> ok | {error, {no_such_group, Name}}
77
78 Types:
79
80 Name = name()
81
82 Joins the process Pid to the group Name. A process can join a
83 group many times and must then leave the group the same number
84 of times.
85
86 leave(Name, Pid :: pid()) -> ok | {error, {no_such_group, Name}}
87
88 Types:
89
90 Name = name()
91
92 Makes the process Pid leave the group Name. If the process is
93 not a member of the group, ok is returned.
94
95 start() -> {ok, pid()} | {error, any()}
96
97 start_link() -> {ok, pid()} | {error, any()}
98
99 Starts the pg2 server. Normally, the server does not need to be
100 started explicitly, as it is started dynamically if it is
101 needed. This is useful during development, but in a target sys‐
102 tem the server is to be started explicitly. Use the configura‐
103 tion parameters for kernel(6) for this.
104
105 which_groups() -> [Name :: name()]
106
107 Returns a list of all known groups.
108
110 kernel(6)
111
112
113
114Ericsson AB kernel 6.3.1.1 pg2(3)