|
@@ -65,9 +65,6 @@ context() = {<a href="#type-scope">scope()</a>, <a href="#type-type">type()</a>}
|
|
|
|
|
|
|
|
|
|
|
|
-{'all','all'} is the default
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
### <a name="type-ctr_incr">ctr_incr()</a> ###
|
|
@@ -123,7 +120,7 @@ ctr_update() = <a href="#type-ctr_incr">ctr_incr()</a> | {<a href="#type-ctr_inc
|
|
|
|
|
|
|
|
|
<pre><code>
|
|
|
-headpat() = {<a href="#type-keypat">keypat()</a>, <a href="#type-pidpat">pidpat()</a>, ValPat}
|
|
|
+headpat() = {<a href="#type-keypat">keypat()</a>, <a href="#type-pidpat">pidpat()</a>, any()}
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
@@ -152,8 +149,6 @@ key() = {<a href="#type-type">type()</a>, <a href="#type-scope">scope()</a>, any
|
|
|
|
|
|
|
|
|
|
|
|
-update_counter increment
|
|
|
-
|
|
|
|
|
|
|
|
|
### <a name="type-keypat">keypat()</a> ###
|
|
@@ -214,7 +209,16 @@ scope() = l | g
|
|
|
|
|
|
|
|
|
|
|
|
-l = local registration; g = global registration
|
|
|
+
|
|
|
+
|
|
|
+### <a name="type-sel_context">sel_context()</a> ###
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+<pre><code>
|
|
|
+sel_context() = {<a href="#type-scope">scope()</a>, <a href="#type-type">type()</a>} | <a href="#type-type">type()</a>
|
|
|
+</code></pre>
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -224,7 +228,7 @@ l = local registration; g = global registration
|
|
|
|
|
|
|
|
|
<pre><code>
|
|
|
-sel_pattern() = [{<a href="#type-headpat">headpat()</a>, Guards, Prod}]
|
|
|
+sel_pattern() = [{<a href="#type-headpat">headpat()</a>, list(), list()}]
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
@@ -248,7 +252,7 @@ sel_scope() = scope | all | global | local
|
|
|
|
|
|
|
|
|
<pre><code>
|
|
|
-sel_type() = <a href="#type-type">type()</a> | names | props | counters | aggr_counters
|
|
|
+sel_type() = <a href="#type-type">type()</a> | names | props | counters | aggr_counters | resources | resource_counters
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
@@ -260,7 +264,7 @@ sel_type() = <a href="#type-type">type()</a> | names | props | counters | aggr_c
|
|
|
|
|
|
|
|
|
<pre><code>
|
|
|
-sel_var() = DollarVar | '_'
|
|
|
+sel_var() = '_' | atom()
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
@@ -272,14 +276,11 @@ sel_var() = DollarVar | '_'
|
|
|
|
|
|
|
|
|
<pre><code>
|
|
|
-type() = n | p | c | a
|
|
|
+type() = n | p | c | a | r | rc
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
|
|
|
|
-n = name; p = property; c = counter;
|
|
|
-a = aggregate_counter
|
|
|
-
|
|
|
|
|
|
|
|
|
### <a name="type-unique_id">unique_id()</a> ###
|
|
@@ -301,7 +302,8 @@ This function is the reverse of monitor/1.</td></tr><tr><td valign="top"><a href
|
|
|
to forget about the calling process.</td></tr><tr><td valign="top"><a href="#i-0">i/0</a></td><td>Similar to the built-in shell command <code>i()</code> but inserts information
|
|
|
about names and properties registered in Gproc, where applicable.</td></tr><tr><td valign="top"><a href="#info-1">info/1</a></td><td>Similar to <code>process_info(Pid)</code> but with additional gproc info.</td></tr><tr><td valign="top"><a href="#info-2">info/2</a></td><td>Similar to process_info(Pid, Item), but with additional gproc info.</td></tr><tr><td valign="top"><a href="#last-1">last/1</a></td><td>Behaves as ets:last(Tab) for a given type of registration.</td></tr><tr><td valign="top"><a href="#lookup_global_aggr_counter-1">lookup_global_aggr_counter/1</a></td><td>Lookup a global (unique) aggregated counter and returns its value.</td></tr><tr><td valign="top"><a href="#lookup_global_counters-1">lookup_global_counters/1</a></td><td>Look up all global (non-unique) instances of a given Counter.</td></tr><tr><td valign="top"><a href="#lookup_global_name-1">lookup_global_name/1</a></td><td>Lookup a global unique name.</td></tr><tr><td valign="top"><a href="#lookup_global_properties-1">lookup_global_properties/1</a></td><td>Look up all global (non-unique) instances of a given Property.</td></tr><tr><td valign="top"><a href="#lookup_local_aggr_counter-1">lookup_local_aggr_counter/1</a></td><td>Lookup a local (unique) aggregated counter and returns its value.</td></tr><tr><td valign="top"><a href="#lookup_local_counters-1">lookup_local_counters/1</a></td><td>Look up all local (non-unique) instances of a given Counter.</td></tr><tr><td valign="top"><a href="#lookup_local_name-1">lookup_local_name/1</a></td><td>Lookup a local unique name.</td></tr><tr><td valign="top"><a href="#lookup_local_properties-1">lookup_local_properties/1</a></td><td>Look up all local (non-unique) instances of a given Property.</td></tr><tr><td valign="top"><a href="#lookup_pid-1">lookup_pid/1</a></td><td>Lookup the Pid stored with a key.</td></tr><tr><td valign="top"><a href="#lookup_pids-1">lookup_pids/1</a></td><td>Returns a list of pids with the published key Key.</td></tr><tr><td valign="top"><a href="#lookup_value-1">lookup_value/1</a></td><td>Lookup the value stored with a key.</td></tr><tr><td valign="top"><a href="#lookup_values-1">lookup_values/1</a></td><td>Retrieve the <code>{Pid,Value}</code> pairs corresponding to Key.</td></tr><tr><td valign="top"><a href="#monitor-1">monitor/1</a></td><td>Equivalent to <a href="#monitor-2"><tt>monitor(Key, info)</tt></a>.</td></tr><tr><td valign="top"><a href="#monitor-2">monitor/2</a></td><td>monitor a registered name
|
|
|
<code>monitor(Key, info)</code> works much like erlang:monitor(process, Pid), but monitors
|
|
|
-a unique name registered via gproc.</td></tr><tr><td valign="top"><a href="#mreg-3">mreg/3</a></td><td>Register multiple {Key,Value} pairs of a given type and scope.</td></tr><tr><td valign="top"><a href="#munreg-3">munreg/3</a></td><td>Unregister multiple Key items of a given type and scope.</td></tr><tr><td valign="top"><a href="#nb_wait-1">nb_wait/1</a></td><td>Wait for a name or aggregated counter to be registered.</td></tr><tr><td valign="top"><a href="#nb_wait-2">nb_wait/2</a></td><td>Wait for a name or aggregated counter to be registered on <code>Node</code>.</td></tr><tr><td valign="top"><a href="#next-2">next/2</a></td><td>Behaves as ets:next(Tab,Key) for a given type of registration.</td></tr><tr><td valign="top"><a href="#prev-2">prev/2</a></td><td>Behaves as ets:prev(Tab,Key) for a given type of registration.</td></tr><tr><td valign="top"><a href="#reg-1">reg/1</a></td><td>Equivalent to <a href="#reg-2"><tt>reg(Key, default(Key))</tt></a>.</td></tr><tr><td valign="top"><a href="#reg-2">reg/2</a></td><td>Register a name or property for the current process.</td></tr><tr><td valign="top"><a href="#reg_or_locate-1">reg_or_locate/1</a></td><td>Equivalent to <a href="#reg_or_locate-2"><tt>reg_or_locate(Key, default(Key))</tt></a>.</td></tr><tr><td valign="top"><a href="#reg_or_locate-2">reg_or_locate/2</a></td><td>Try registering a unique name, or return existing registration.</td></tr><tr><td valign="top"><a href="#reg_or_locate-3">reg_or_locate/3</a></td><td>Spawn a process with a registered name, or return existing registration.</td></tr><tr><td valign="top"><a href="#reg_shared-1">reg_shared/1</a></td><td>Register a resource, but don't tie it to a particular process.</td></tr><tr><td valign="top"><a href="#reg_shared-2">reg_shared/2</a></td><td>Register a resource, but don't tie it to a particular process.</td></tr><tr><td valign="top"><a href="#register_name-2">register_name/2</a></td><td>Behaviour support callback.</td></tr><tr><td valign="top"><a href="#reset_counter-1">reset_counter/1</a></td><td>Reads and resets a counter in a "thread-safe" way.</td></tr><tr><td valign="top"><a href="#select-1">select/1</a></td><td>Perform a select operation on the process registry.</td></tr><tr><td valign="top"><a href="#select-2">select/2</a></td><td>Perform a select operation with limited context on the process registry.</td></tr><tr><td valign="top"><a href="#select-3">select/3</a></td><td>Like <a href="#select-2"><code>select/2</code></a> but returns Limit objects at a time.</td></tr><tr><td valign="top"><a href="#select_count-1">select_count/1</a></td><td>Equivalent to <a href="#select_count-2"><tt>select_count(all, Pat)</tt></a>.</td></tr><tr><td valign="top"><a href="#select_count-2">select_count/2</a></td><td>Perform a select_count operation on the process registry.</td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td>Sends a message to the process, or processes, corresponding to Key.</td></tr><tr><td valign="top"><a href="#set_attributes-2">set_attributes/2</a></td><td>Add/modify <code>{Key, Value}</code> attributes associated with a registration.</td></tr><tr><td valign="top"><a href="#set_attributes_shared-2">set_attributes_shared/2</a></td><td>Add/modify <code>{Key, Value}</code> attributes associated with a shared registration.</td></tr><tr><td valign="top"><a href="#set_env-5">set_env/5</a></td><td>Updates the cached value as well as underlying environment.</td></tr><tr><td valign="top"><a href="#set_value-2">set_value/2</a></td><td>Sets the value of the registration given by Key.</td></tr><tr><td valign="top"><a href="#set_value_shared-2">set_value_shared/2</a></td><td>Sets the value of the shared registration given by Key.</td></tr><tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td>Starts the gproc server.</td></tr><tr><td valign="top"><a href="#table-0">table/0</a></td><td>Equivalent to <a href="#table-1"><tt>table({all, all})</tt></a>.</td></tr><tr><td valign="top"><a href="#table-1">table/1</a></td><td>Equivalent to <a href="#table-2"><tt>table(Context, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#table-2">table/2</a></td><td>QLC table generator for the gproc registry.</td></tr><tr><td valign="top"><a href="#unreg-1">unreg/1</a></td><td>Unregister a name or property.</td></tr><tr><td valign="top"><a href="#unreg_shared-1">unreg_shared/1</a></td><td>Unregister a shared resource.</td></tr><tr><td valign="top"><a href="#unregister_name-1">unregister_name/1</a></td><td>Equivalent to <tt>unreg / 1</tt>.</td></tr><tr><td valign="top"><a href="#update_counter-2">update_counter/2</a></td><td>Updates the counter registered as Key for the current process.</td></tr><tr><td valign="top"><a href="#update_counter-3">update_counter/3</a></td><td></td></tr><tr><td valign="top"><a href="#update_counters-2">update_counters/2</a></td><td>Update a list of counters.</td></tr><tr><td valign="top"><a href="#update_shared_counter-2">update_shared_counter/2</a></td><td>Updates the shared counter registered as Key.</td></tr><tr><td valign="top"><a href="#where-1">where/1</a></td><td>Returns the pid registered as Key.</td></tr><tr><td valign="top"><a href="#whereis_name-1">whereis_name/1</a></td><td>Equivalent to <tt>where / 1</tt>.</td></tr><tr><td valign="top"><a href="#wide_await-3">wide_await/3</a></td><td>Wait for a local name to be registered on any of <code>Nodes</code>.</td></tr></table>
|
|
|
+a unique name registered via gproc.</td></tr><tr><td valign="top"><a href="#mreg-3">mreg/3</a></td><td>Register multiple {Key,Value} pairs of a given type and scope.</td></tr><tr><td valign="top"><a href="#munreg-3">munreg/3</a></td><td>Unregister multiple Key items of a given type and scope.</td></tr><tr><td valign="top"><a href="#nb_wait-1">nb_wait/1</a></td><td>Wait for a name or aggregated counter to be registered.</td></tr><tr><td valign="top"><a href="#nb_wait-2">nb_wait/2</a></td><td>Wait for a name or aggregated counter to be registered on <code>Node</code>.</td></tr><tr><td valign="top"><a href="#next-2">next/2</a></td><td>Behaves as ets:next(Tab,Key) for a given type of registration.</td></tr><tr><td valign="top"><a href="#prev-2">prev/2</a></td><td>Behaves as ets:prev(Tab,Key) for a given type of registration.</td></tr><tr><td valign="top"><a href="#reg-1">reg/1</a></td><td>Equivalent to <a href="#reg-3"><tt>reg(Key, default(Key), [])</tt></a>.</td></tr><tr><td valign="top"><a href="#reg-2">reg/2</a></td><td>Register a name or property for the current process.</td></tr><tr><td valign="top"><a href="#reg-3">reg/3</a></td><td>Register a name or property for the current process
|
|
|
+<code>Attrs</code> (default: <code>[]</code>) can be inspected using <a href="#get_attribute-2"><code>get_attribute/2</code></a>.</td></tr><tr><td valign="top"><a href="#reg_or_locate-1">reg_or_locate/1</a></td><td>Equivalent to <a href="#reg_or_locate-2"><tt>reg_or_locate(Key, default(Key))</tt></a>.</td></tr><tr><td valign="top"><a href="#reg_or_locate-2">reg_or_locate/2</a></td><td>Try registering a unique name, or return existing registration.</td></tr><tr><td valign="top"><a href="#reg_or_locate-3">reg_or_locate/3</a></td><td>Spawn a process with a registered name, or return existing registration.</td></tr><tr><td valign="top"><a href="#reg_shared-1">reg_shared/1</a></td><td>Register a resource, but don't tie it to a particular process.</td></tr><tr><td valign="top"><a href="#reg_shared-2">reg_shared/2</a></td><td>Register a resource, but don't tie it to a particular process.</td></tr><tr><td valign="top"><a href="#reg_shared-3">reg_shared/3</a></td><td></td></tr><tr><td valign="top"><a href="#register_name-2">register_name/2</a></td><td>Behaviour support callback.</td></tr><tr><td valign="top"><a href="#reset_counter-1">reset_counter/1</a></td><td>Reads and resets a counter in a "thread-safe" way.</td></tr><tr><td valign="top"><a href="#select-1">select/1</a></td><td>Perform a select operation on the process registry.</td></tr><tr><td valign="top"><a href="#select-2">select/2</a></td><td>Perform a select operation with limited context on the process registry.</td></tr><tr><td valign="top"><a href="#select-3">select/3</a></td><td>Like <a href="#select-2"><code>select/2</code></a> but returns Limit objects at a time.</td></tr><tr><td valign="top"><a href="#select_count-1">select_count/1</a></td><td>Equivalent to <a href="#select_count-2"><tt>select_count(all, Pat)</tt></a>.</td></tr><tr><td valign="top"><a href="#select_count-2">select_count/2</a></td><td>Perform a select_count operation on the process registry.</td></tr><tr><td valign="top"><a href="#send-2">send/2</a></td><td>Sends a message to the process, or processes, corresponding to Key.</td></tr><tr><td valign="top"><a href="#set_attributes-2">set_attributes/2</a></td><td>Add/modify <code>{Key, Value}</code> attributes associated with a registration.</td></tr><tr><td valign="top"><a href="#set_attributes_shared-2">set_attributes_shared/2</a></td><td>Add/modify <code>{Key, Value}</code> attributes associated with a shared registration.</td></tr><tr><td valign="top"><a href="#set_env-5">set_env/5</a></td><td>Updates the cached value as well as underlying environment.</td></tr><tr><td valign="top"><a href="#set_value-2">set_value/2</a></td><td>Sets the value of the registration given by Key.</td></tr><tr><td valign="top"><a href="#set_value_shared-2">set_value_shared/2</a></td><td>Sets the value of the shared registration given by Key.</td></tr><tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td>Starts the gproc server.</td></tr><tr><td valign="top"><a href="#table-0">table/0</a></td><td>Equivalent to <a href="#table-1"><tt>table({all, all})</tt></a>.</td></tr><tr><td valign="top"><a href="#table-1">table/1</a></td><td>Equivalent to <a href="#table-2"><tt>table(Context, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#table-2">table/2</a></td><td>QLC table generator for the gproc registry.</td></tr><tr><td valign="top"><a href="#unreg-1">unreg/1</a></td><td>Unregister a name or property.</td></tr><tr><td valign="top"><a href="#unreg_shared-1">unreg_shared/1</a></td><td>Unregister a shared resource.</td></tr><tr><td valign="top"><a href="#unregister_name-1">unregister_name/1</a></td><td>Equivalent to <tt>unreg / 1</tt>.</td></tr><tr><td valign="top"><a href="#update_counter-2">update_counter/2</a></td><td>Updates the counter registered as Key for the current process.</td></tr><tr><td valign="top"><a href="#update_counter-3">update_counter/3</a></td><td></td></tr><tr><td valign="top"><a href="#update_counters-2">update_counters/2</a></td><td>Update a list of counters.</td></tr><tr><td valign="top"><a href="#update_shared_counter-2">update_shared_counter/2</a></td><td>Updates the shared counter registered as Key.</td></tr><tr><td valign="top"><a href="#where-1">where/1</a></td><td>Returns the pid registered as Key.</td></tr><tr><td valign="top"><a href="#whereis_name-1">whereis_name/1</a></td><td>Equivalent to <tt>where / 1</tt>.</td></tr><tr><td valign="top"><a href="#wide_await-3">wide_await/3</a></td><td>Wait for a local name to be registered on any of <code>Nodes</code>.</td></tr></table>
|
|
|
|
|
|
|
|
|
<a name="functions"></a>
|
|
@@ -1207,7 +1209,7 @@ reg(Key::<a href="#type-key">key()</a>) -> true
|
|
|
</code></pre>
|
|
|
<br />
|
|
|
|
|
|
-Equivalent to [`reg(Key, default(Key))`](#reg-2).
|
|
|
+Equivalent to [`reg(Key, default(Key), [])`](#reg-3).
|
|
|
<a name="reg-2"></a>
|
|
|
|
|
|
### reg/2 ###
|
|
@@ -1223,6 +1225,64 @@ Register a name or property for the current process
|
|
|
|
|
|
|
|
|
|
|
|
+<a name="reg-3"></a>
|
|
|
+
|
|
|
+### reg/3 ###
|
|
|
+
|
|
|
+
|
|
|
+<pre><code>
|
|
|
+reg(Key::<a href="#type-key">key()</a>, Value, Attrs::[{atom(), any()}]) -> true
|
|
|
+</code></pre>
|
|
|
+<br />
|
|
|
+
|
|
|
+
|
|
|
+Register a name or property for the current process
|
|
|
+`Attrs` (default: `[]`) can be inspected using [`get_attribute/2`](#get_attribute-2).
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+The structure of `Key` is `{Type, Context, Name}`, where:
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+* `Context :: l | g` - `l` means 'local' context; `g` means 'global'
|
|
|
+* `Type :: p | n | c | a | r | rc` specifies the type of entry
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+The semantics of the different types:
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+* `p` - 'property', is non-unique, i.e. different processes can each
|
|
|
+register a property with the same name.
|
|
|
+* `n` - 'name, is unique within the given context (local or global).
|
|
|
+* `c` - 'counter', is similar to a property, but has a numeric value
|
|
|
+and behaves roughly as an ets counter (see [`update_counter/2`](#update_counter-2).)
|
|
|
+* `a` - 'aggregated counter', is automatically updated by gproc, and
|
|
|
+reflects the sum of all counter objects with the same name in the given
|
|
|
+scope. The initial value for an aggregated counter must be `undefined`.
|
|
|
+* `r` - 'resource property', behaves like a property, but can be tracked
|
|
|
+with a 'resource counter'.
|
|
|
+* `rc` - 'resource counter', tracks the number of resource properties
|
|
|
+with the same name. When the resource count reaches `0`, any triggers
|
|
|
+specified using an `on_zero` attribute may be executed (see below).
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+On-zero triggers:
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+`Msg = {gproc, resource_on_zero, Context, Name, Pid}`
|
|
|
+
|
|
|
+
|
|
|
+* `{send, Key}` - run `gproc:send(Key, Msg)`
|
|
|
+* `{bcast, Key}` - run `gproc:bcast(Key, Msg)`
|
|
|
+* `publish` - run
|
|
|
+`gproc_ps:publish(Context, gproc_resource_on_zero, {Context, Name, Pid})`
|
|
|
+* `{unreg_shared, Type, Name}` - unregister the shared key
|
|
|
+`{Type, Context, Name}`
|
|
|
<a name="reg_or_locate-1"></a>
|
|
|
|
|
|
### reg_or_locate/1 ###
|
|
@@ -1315,6 +1375,13 @@ increment the shared counter `myCounter` with 1, provided it exists.
|
|
|
|
|
|
A shared aggregated counter will track updates in exactly the same way as
|
|
|
an aggregated counter which is owned by a process.
|
|
|
+<a name="reg_shared-3"></a>
|
|
|
+
|
|
|
+### reg_shared/3 ###
|
|
|
+
|
|
|
+`reg_shared(Key, Value, Attrs) -> any()`
|
|
|
+
|
|
|
+
|
|
|
<a name="register_name-2"></a>
|
|
|
|
|
|
### register_name/2 ###
|
|
@@ -1396,7 +1463,7 @@ representation for the gproc select operations is given by
|
|
|
|
|
|
|
|
|
<pre><code>
|
|
|
-select(Context::<a href="#type-context">context()</a>, Pat::<a href="#type-sel_pattern">sel_pattern()</a>) -> [{Key, Pid, Value}]
|
|
|
+select(Context::<a href="#type-sel_context">sel_context()</a>, Pat::<a href="#type-sel_pattern">sel_pattern()</a>) -> [{Key, Pid, Value}]
|
|
|
</code></pre>
|
|
|
<br />
|
|
|
|