Skip to content

Commit

Permalink
doc fixes + revert to shortnames in dist_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Wiger committed Apr 27, 2011
1 parent dd5d9d2 commit f096466
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 16 deletions.
45 changes: 36 additions & 9 deletions doc/gproc.md
Expand Up @@ -88,19 +88,24 @@ Type and scope for registration and lookup:
sel_var() = DollarVar | '_'.


<h3 class="typedecl"><a name="type-scope">scope()</a></h3>
<h3 class="typedecl"><a name="type-reg_id">reg_id()</a></h3>




<pre>scope() = l | g</pre>
<pre>reg_id() = {<a href="#type-type">type()</a>, <a href="#type-scope">scope()</a>, any()}</pre>



<h3 class="typedecl"><a name="type-scope">scope()</a></h3>

l = local registration; g = global registration

Type and scope for select(), qlc() and stepping:


<pre>scope() = l | g</pre>


l = local registration; g = global registration



Expand Down Expand Up @@ -142,6 +147,18 @@ Type and scope for select(), qlc() and stepping:
n = name; p = property; c = counter;
a = aggregate_counter


<h3 class="typedecl"><a name="type-unique_id">unique_id()</a></h3>




<pre>unique_id() = {n | a, <a href="#type-scope">scope()</a>, any()}</pre>


Type and scope for select(), qlc() and stepping:


<h2><a name="index">Function Index</a></h2>


Expand Down Expand Up @@ -361,7 +378,7 @@ Equivalent to [`get_env(Scope, App, Key, [app_env])`](#get_env-4).<a name="get_e


<pre>get_env(Scope::<a href="#type-scope">scope()</a>, App::atom(), Key::atom(), Strategy) -> term()</pre>
<ul class="definitions"><li><pre>Strategy = [Alternative]</pre></li><li><pre>Alternative = app_env | os_env | inherit | {inherit, pid()} | {default, term()} | error</pre></li></ul>
<ul class="definitions"><li><pre>Strategy = [Alternative]</pre></li><li><pre>Alternative = app_env | os_env | inherit | {inherit, pid()} | {inherit, <a href="#type-unique_id">unique_id()</a>} | init_arg | {mnesia, ActivityType, Oid, Pos} | {default, term()} | error</pre></li></ul>



Expand All @@ -384,8 +401,8 @@ uppercase string
* `{os_env, ENV}` - try `os:getenv(ENV)`
* `inherit` - inherit the cached value, if any, held by the (proc_lib) parent.
* `{inherit, Pid}` - inherit the cached value, if any, held by `Pid`.
* `{inherit, Name}` - inherit the cached value, if any, held by the process
registered in `gproc` as `Name`.
* `{inherit, Id}` - inherit the cached value, if any, held by the process
registered in `gproc` as `Id`.
* `init_arg` - try `init:get_argument(Key)`; expects a single value, if any.
* `{mnesia, ActivityType, Oid, Pos}` - try
`mnesia:activity(ActivityType, fun() -> mnesia:read(Oid) end)`; retrieve the
Expand All @@ -397,8 +414,18 @@ exhausted; if not set, `undefined` will be returned.


While any alternative can occur more than once, the only one that might make
sense to repeat is `{default, Value}`.
The last instance will be the one that determines the return value.
sense to use multiple times is `{default, Value}`.



The return value will be one of:



* The value of the first matching alternative, or exception caused by `error`,
whichever comes first
* The last instance of `{default, Value}`, or `undefined`, if there is no
matching alternative, default or `error` entry in the list.

The `error` option can be used to assert that a value has been previously
cached. Alternatively, it can be used to assert that a value is either cached
Expand Down
2 changes: 1 addition & 1 deletion src/gproc.app.src
Expand Up @@ -5,7 +5,7 @@
{application, gproc,
[
{description, "GPROC"},
{vsn, "0.2.6"},
{vsn, "0.2.7"},
{id, "GPROC"},
{registered, [ ] },
%% NOTE: do not list applications which are load-only!
Expand Down
21 changes: 16 additions & 5 deletions src/gproc.erl
Expand Up @@ -26,6 +26,9 @@
%% a = aggregate_counter
%% @type scope() = l | g. l = local registration; g = global registration
%%
%% @type reg_id() = {type(), scope(), any()}.
%% @type unique_id() = {n | a, scope(), any()}.
%%
%% Type and scope for select(), qlc() and stepping:
%%
%% @type sel_scope() = scope | all | global | local.
Expand Down Expand Up @@ -283,7 +286,9 @@ get_env(Scope, App, Key) ->
%% Strategy = [Alternative]
%% Alternative = app_env
%% | os_env
%% | inherit | {inherit, pid()}
%% | inherit | {inherit, pid()} | {inherit, unique_id()}
%% | init_arg
%% | {mnesia, ActivityType, Oid, Pos}
%% | {default, term()}
%% | error
%% @doc Fetch an environment value, potentially cached as a `gproc_env' property.
Expand All @@ -299,8 +304,8 @@ get_env(Scope, App, Key) ->
%% * `{os_env, ENV}' - try `os:getenv(ENV)'
%% * `inherit' - inherit the cached value, if any, held by the (proc_lib) parent.
%% * `{inherit, Pid}' - inherit the cached value, if any, held by `Pid'.
%% * `{inherit, Name}' - inherit the cached value, if any, held by the process
%% registered in `gproc' as `Name'.
%% * `{inherit, Id}' - inherit the cached value, if any, held by the process
%% registered in `gproc' as `Id'.
%% * `init_arg' - try `init:get_argument(Key)'; expects a single value, if any.
%% * `{mnesia, ActivityType, Oid, Pos}' - try
%% `mnesia:activity(ActivityType, fun() -> mnesia:read(Oid) end)'; retrieve the
Expand All @@ -310,8 +315,14 @@ get_env(Scope, App, Key) ->
%% * `error' - raise an exception, `erlang:error(gproc_env, [App, Key, Scope])'.
%%
%% While any alternative can occur more than once, the only one that might make
%% sense to repeat is `{default, Value}'.
%% The last instance will be the one that determines the return value.
%% sense to use multiple times is `{default, Value}'.
%%
%% The return value will be one of:
%%
%% * The value of the first matching alternative, or exception caused by `error',
%% whichever comes first
%% * The last instance of `{default, Value}', or `undefined', if there is no
%% matching alternative, default or `error' entry in the list.
%%
%% The `error' option can be used to assert that a value has been previously
%% cached. Alternatively, it can be used to assert that a value is either cached
Expand Down
2 changes: 1 addition & 1 deletion test/gproc_dist_tests.erl
Expand Up @@ -260,7 +260,7 @@ start_slave(Name) ->
case node() of
nonode@nohost ->
os:cmd("epmd -daemon"),
{ok, _} = net_kernel:start([gproc_master, longnames]);
{ok, _} = net_kernel:start([gproc_master, shortnames]);
_ ->
ok
end,
Expand Down

0 comments on commit f096466

Please sign in to comment.