Browse Source

Doc fixes re. issue #76

Ulf Wiger 10 years ago
parent
commit
46238dea57
2 changed files with 18 additions and 8 deletions
  1. 10 4
      doc/gproc.md
  2. 8 4
      src/gproc.erl

+ 10 - 4
doc/gproc.md

@@ -997,8 +997,11 @@ lookup_pid(Key) -> Pid
 </code></pre>
 <br />
 
+
 Lookup the Pid stored with a key.
 
+
+This function raises a `badarg` exception if `Key` is not registered.
 <a name="lookup_pids-1"></a>
 
 ### lookup_pids/1 ###
@@ -1031,8 +1034,11 @@ lookup_value(Key) -&gt; Value
 </code></pre>
 <br />
 
+
 Lookup the value stored with a key.
 
+
+This function raises a `badarg` exception if `Key` is not registered.
 <a name="lookup_values-1"></a>
 
 ### lookup_values/1 ###
@@ -1218,7 +1224,7 @@ Register a name or property for the current process
 
 
 <pre><code>
-reg_or_locate(Key::<a href="#type-key">key()</a>) -&gt; true
+reg_or_locate(Key::<a href="#type-key">key()</a>) -&gt; {pid(), NewValue}
 </code></pre>
 <br />
 
@@ -1755,7 +1761,7 @@ that the position is omitted; in gproc, the value position is always `3`.
 
 
 <pre><code>
-where(Key::<a href="#type-key">key()</a>) -&gt; pid()
+where(Key::<a href="#type-key">key()</a>) -&gt; pid() | undefined
 </code></pre>
 <br />
 
@@ -1764,8 +1770,8 @@ Returns the pid registered as Key
 
 
 The type of registration must be either name or aggregated counter.
-Otherwise this function will exit. Use [`lookup_pids/1`](#lookup_pids-1) in these
-cases.
+Otherwise this function will raise a `badarg` exception.
+Use [`lookup_pids/1`](#lookup_pids-1) in these cases.
 <a name="whereis_name-1"></a>
 
 ### whereis_name/1 ###

+ 8 - 4
src/gproc.erl

@@ -609,7 +609,7 @@ reg(Key) ->
 reg1(Key) ->
     reg1(Key, default(Key)).
 
-%% @spec reg_or_locate(Key::key()) -> true
+%% @spec reg_or_locate(Key::key()) -> {pid(), NewValue}
 %%
 %% @doc
 %% @equiv reg_or_locate(Key, default(Key))
@@ -1490,6 +1490,8 @@ get_attributes1(_, _) ->
 %% @spec (Key) -> Pid
 %% @doc Lookup the Pid stored with a key.
 %%
+%% This function raises a `badarg' exception if `Key' is not registered.
+%% @end
 lookup_pid({_T,_,_} = Key) ->
     case where(Key) of
         undefined -> erlang:error(badarg);
@@ -1499,6 +1501,8 @@ lookup_pid({_T,_,_} = Key) ->
 %% @spec (Key) -> Value
 %% @doc Lookup the value stored with a key.
 %%
+%% This function raises a `badarg' exception if `Key' is not registered.
+%% @end
 lookup_value({T,_,_} = Key) ->
     if T==n orelse T==a ->
             ets:lookup_element(?TAB, {Key,T}, 3);
@@ -1506,13 +1510,13 @@ lookup_value({T,_,_} = Key) ->
             erlang:error(badarg)
     end.
 
-%% @spec (Key::key()) -> pid()
+%% @spec (Key::key()) -> pid() | undefined
 %%
 %% @doc Returns the pid registered as Key
 %%
 %% The type of registration must be either name or aggregated counter.
-%% Otherwise this function will exit. Use {@link lookup_pids/1} in these
-%% cases.
+%% Otherwise this function will raise a `badarg' exception.
+%% Use {@link lookup_pids/1} in these cases.
 %% @end
 %%
 where(Key) ->