gproc.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Module gproc</title>
  5. <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
  6. </head>
  7. <body bgcolor="white">
  8. <div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  9. <hr>
  10. <h1>Module gproc</h1>
  11. <ul class="index"><li><a href="#description">Description</a></li><li><a href="#types">Data Types</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Extended process registry.
  12. <p><b>Behaviours:</b> <a href="gen_server.html"><tt>gen_server</tt></a>.</p>
  13. <p><b>Authors:</b> Ulf Wiger (<a href="mailto:ulf.wiger@erlang-consulting.com"><tt>ulf.wiger@erlang-consulting.com</tt></a>).</p>
  14. <h2><a name="description">Description</a></h2>Extended process registry
  15. <p>This module implements an extended process registry</p>
  16. <p>For a detailed description, see
  17. <a href="erlang07-wiger.pdf">erlang07-wiger.pdf</a>.</p>
  18. <h2><a name="types">Data Types</a></h2>
  19. <h3 class="typedecl"><a name="type-context">context()</a></h3>
  20. <p><tt>context() = {<a href="#type-scope">scope()</a>, <a href="#type-type">type()</a>} | <a href="#type-type">type()</a></tt></p>
  21. <p>Local scope is the default</p>
  22. <h3 class="typedecl"><a name="type-headpat">headpat()</a></h3>
  23. <p><tt>headpat() = {<a href="#type-keypat">keypat()</a>, <a href="#type-pidpat">pidpat()</a>, ValPat}</tt></p>
  24. <h3 class="typedecl"><a name="type-key">key()</a></h3>
  25. <p><tt>key() = {<a href="#type-type">type()</a>, <a href="#type-scope">scope()</a>, any()}</tt></p>
  26. <h3 class="typedecl"><a name="type-keypat">keypat()</a></h3>
  27. <p><tt>keypat() = {<a href="#type-sel_type">sel_type()</a> | <a href="#type-sel_var">sel_var()</a>, l | g | <a href="#type-sel_var">sel_var()</a>, any()}</tt></p>
  28. <h3 class="typedecl"><a name="type-pidpat">pidpat()</a></h3>
  29. <p><tt>pidpat() = pid() | <a href="#type-sel_var">sel_var()</a></tt></p>
  30. <p>sel_var() = DollarVar | '_'.</p>
  31. <h3 class="typedecl"><a name="type-scope">scope()</a></h3>
  32. <p><tt>scope() = l | g</tt></p>
  33. <p>l = local registration; g = global registration</p>
  34. <h3 class="typedecl"><a name="type-sel_pattern">sel_pattern()</a></h3>
  35. <p><tt>sel_pattern() = [{<a href="#type-headpat">headpat()</a>, Guards, Prod}]</tt></p>
  36. <h3 class="typedecl"><a name="type-sel_type">sel_type()</a></h3>
  37. <p><tt>sel_type() = n | p | c | a | names | props | counters | aggr_counters</tt></p>
  38. <h3 class="typedecl"><a name="type-type">type()</a></h3>
  39. <p><tt>type() = n | p | c | a</tt></p>
  40. <p>n = name; p = property; c = counter;
  41. a = aggregate_counter</p>
  42. <h2><a name="index">Function Index</a></h2>
  43. <table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#add_global_aggr_counter-1">add_global_aggr_counter/1</a></td><td>Registers a global (unique) aggregated counter.</td></tr>
  44. <tr><td valign="top"><a href="#add_global_counter-2">add_global_counter/2</a></td><td>Registers a global (non-unique) counter.</td></tr>
  45. <tr><td valign="top"><a href="#add_global_name-1">add_global_name/1</a></td><td>Registers a global (unique) name.</td></tr>
  46. <tr><td valign="top"><a href="#add_global_property-2">add_global_property/2</a></td><td>Registers a global (non-unique) property.</td></tr>
  47. <tr><td valign="top"><a href="#add_local_aggr_counter-1">add_local_aggr_counter/1</a></td><td>Registers a local (unique) aggregated counter.</td></tr>
  48. <tr><td valign="top"><a href="#add_local_counter-2">add_local_counter/2</a></td><td>Registers a local (non-unique) counter.</td></tr>
  49. <tr><td valign="top"><a href="#add_local_name-1">add_local_name/1</a></td><td>Registers a local (unique) name.</td></tr>
  50. <tr><td valign="top"><a href="#add_local_property-2">add_local_property/2</a></td><td>Registers a local (non-unique) property.</td></tr>
  51. <tr><td valign="top"><a href="#await-2">await/2</a></td><td>Wait for a local name to be registered.</td></tr>
  52. <tr><td valign="top"><a href="#cancel_wait-2">cancel_wait/2</a></td><td></td></tr>
  53. <tr><td valign="top"><a href="#default-1">default/1</a></td><td></td></tr>
  54. <tr><td valign="top"><a href="#first-1">first/1</a></td><td>Behaves as ets:first(Tab) for a given type of registration object.</td></tr>
  55. <tr><td valign="top"><a href="#get_value-1">get_value/1</a></td><td>Read the value stored with a key registered to the current process.</td></tr>
  56. <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>
  57. <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>
  58. <tr><td valign="top"><a href="#last-1">last/1</a></td><td>Behaves as ets:last(Tab) for a given type of registration object.</td></tr>
  59. <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>
  60. <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>
  61. <tr><td valign="top"><a href="#lookup_global_name-1">lookup_global_name/1</a></td><td>Lookup a global unique name.</td></tr>
  62. <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>
  63. <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>
  64. <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>
  65. <tr><td valign="top"><a href="#lookup_local_name-1">lookup_local_name/1</a></td><td>Lookup a local unique name.</td></tr>
  66. <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>
  67. <tr><td valign="top"><a href="#lookup_pid-1">lookup_pid/1</a></td><td>Lookup the Pid stored with a key.</td></tr>
  68. <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>
  69. <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>
  70. <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>
  71. <tr><td valign="top"><a href="#nb_wait-1">nb_wait/1</a></td><td>Wait for a local name to be registered.</td></tr>
  72. <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 object.</td></tr>
  73. <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 object.</td></tr>
  74. <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>.
  75. </td></tr>
  76. <tr><td valign="top"><a href="#reg-2">reg/2</a></td><td>Register a name or property for the current process.</td></tr>
  77. <tr><td valign="top"><a href="#select-1">select/1</a></td><td>Equivalent to <a href="#select-2"><tt>select(all, Pat)</tt></a>.
  78. </td></tr>
  79. <tr><td valign="top"><a href="#select-2">select/2</a></td><td>Perform a select operation on the process registry.</td></tr>
  80. <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>
  81. <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>
  82. <tr><td valign="top"><a href="#set_value-2">set_value/2</a></td><td>Sets the value of the registeration entry given by Key.</td></tr>
  83. <tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td>Starts the gproc server.</td></tr>
  84. <tr><td valign="top"><a href="#table-1">table/1</a></td><td>Equivalent to <a href="#table-2"><tt>table(Context, [])</tt></a>.
  85. </td></tr>
  86. <tr><td valign="top"><a href="#table-2">table/2</a></td><td>QLC table generator for the gproc registry.</td></tr>
  87. <tr><td valign="top"><a href="#unreg-1">unreg/1</a></td><td>Unregister a name or property.</td></tr>
  88. <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>
  89. <tr><td valign="top"><a href="#where-1">where/1</a></td><td>Returns the pid registered as Key.</td></tr>
  90. </table>
  91. <h2><a name="functions">Function Details</a></h2>
  92. <h3 class="function"><a name="add_global_aggr_counter-1">add_global_aggr_counter/1</a></h3>
  93. <div class="spec">
  94. <p><tt>add_global_aggr_counter(Name) -&gt; any()</tt></p>
  95. </div><p>Equivalent to <a href="#reg-1"><tt>reg({a, g, Name})</tt></a>.</p>
  96. <p>Registers a global (unique) aggregated counter.</p>
  97. <h3 class="function"><a name="add_global_counter-2">add_global_counter/2</a></h3>
  98. <div class="spec">
  99. <p><tt>add_global_counter(Name, Initial) -&gt; any()</tt></p>
  100. </div><p>Registers a global (non-unique) counter. @equiv reg({c,g,Name},Value)</p>
  101. <h3 class="function"><a name="add_global_name-1">add_global_name/1</a></h3>
  102. <div class="spec">
  103. <p><tt>add_global_name(Name) -&gt; any()</tt></p>
  104. </div><p>Registers a global (unique) name. @equiv reg({n,g,Name})</p>
  105. <h3 class="function"><a name="add_global_property-2">add_global_property/2</a></h3>
  106. <div class="spec">
  107. <p><tt>add_global_property(Name, Value) -&gt; any()</tt></p>
  108. </div><p>Registers a global (non-unique) property. @equiv reg({p,g,Name},Value)</p>
  109. <h3 class="function"><a name="add_local_aggr_counter-1">add_local_aggr_counter/1</a></h3>
  110. <div class="spec">
  111. <p><tt>add_local_aggr_counter(Name) -&gt; any()</tt></p>
  112. </div><p>Equivalent to <a href="#reg-1"><tt>reg({a, l, Name})</tt></a>.</p>
  113. <p>Registers a local (unique) aggregated counter.</p>
  114. <h3 class="function"><a name="add_local_counter-2">add_local_counter/2</a></h3>
  115. <div class="spec">
  116. <p><tt>add_local_counter(Name, Initial) -&gt; any()</tt></p>
  117. </div><p>Registers a local (non-unique) counter. @equiv reg({c,l,Name},Value)</p>
  118. <h3 class="function"><a name="add_local_name-1">add_local_name/1</a></h3>
  119. <div class="spec">
  120. <p><tt>add_local_name(Name) -&gt; any()</tt></p>
  121. </div><p>Registers a local (unique) name. @equiv reg({n,l,Name})</p>
  122. <h3 class="function"><a name="add_local_property-2">add_local_property/2</a></h3>
  123. <div class="spec">
  124. <p><tt>add_local_property(Name, Value) -&gt; any()</tt></p>
  125. </div><p>Registers a local (non-unique) property. @equiv reg({p,l,Name},Value)</p>
  126. <h3 class="function"><a name="await-2">await/2</a></h3>
  127. <div class="spec">
  128. <p><tt>await(Key::<a href="#type-key">key()</a>, Timeout) -&gt; {pid(), Value}</tt>
  129. <ul class="definitions"><li><tt>Timeout = integer() | infinity</tt></li>
  130. </ul></p>
  131. </div><p>Wait for a local name to be registered.
  132. The function raises an exception if the timeout expires. Timeout must be
  133. either an interger &gt; 0 or 'infinity'.</p>
  134. <h3 class="function"><a name="cancel_wait-2">cancel_wait/2</a></h3>
  135. <div class="spec">
  136. <p><tt>cancel_wait(Key, Ref) -&gt; any()</tt></p>
  137. </div>
  138. <h3 class="function"><a name="default-1">default/1</a></h3>
  139. <div class="spec">
  140. <p><tt>default(X1) -&gt; any()</tt></p>
  141. </div>
  142. <h3 class="function"><a name="first-1">first/1</a></h3>
  143. <div class="spec">
  144. <p><tt>first(Type::<a href="#type-type">type()</a>) -&gt; <a href="#type-key">key()</a> | '$end_of_table'</tt></p>
  145. </div><p><p>Behaves as ets:first(Tab) for a given type of registration object.</p>
  146. See <a href="http://www.erlang.org/doc/man/ets.html#first-1" target="_top"><tt>http://www.erlang.org/doc/man/ets.html#first-1</tt></a>.
  147. The registry behaves as an ordered_set table.</p>
  148. <h3 class="function"><a name="get_value-1">get_value/1</a></h3>
  149. <div class="spec">
  150. <p><tt>get_value(Key) -&gt; Value</tt></p>
  151. </div><p><p>Read the value stored with a key registered to the current process.</p>
  152. If no such key is registered to the current process, this function exits.</p>
  153. <h3 class="function"><a name="info-1">info/1</a></h3>
  154. <div class="spec">
  155. <p><tt>info(Pid::pid()) -&gt; ProcessInfo</tt>
  156. <ul class="definitions"><li><tt>ProcessInfo = [{gproc, [{Key, Value}]} | ProcessInfo]</tt></li>
  157. </ul></p>
  158. </div><p><p>Similar to <code>process_info(Pid)</code> but with additional gproc info.</p>
  159. Returns the same information as process_info(Pid), but with the
  160. addition of a <code>gproc</code> information item, containing the <code>{Key,Value}</code>
  161. pairs registered to the process.</p>
  162. <h3 class="function"><a name="info-2">info/2</a></h3>
  163. <div class="spec">
  164. <p><tt>info(Pid::pid(), Item::atom()) -&gt; {Item, Info}</tt></p>
  165. </div><p><p>Similar to process_info(Pid, Item), but with additional gproc info.</p>
  166. For <code>Item = gproc</code>, this function returns a list of <code>{Key, Value}</code> pairs
  167. registered to the process Pid. For other values of Item, it returns the
  168. same as <a href="http://www.erlang.org/doc/man/erlang.html#process_info-2" target="_top"><tt>http://www.erlang.org/doc/man/erlang.html#process_info-2</tt></a>.</p>
  169. <h3 class="function"><a name="last-1">last/1</a></h3>
  170. <div class="spec">
  171. <p><tt>last(Context::<a href="#type-context">context()</a>) -&gt; <a href="#type-key">key()</a> | '$end_of_table'</tt></p>
  172. </div><p><p>Behaves as ets:last(Tab) for a given type of registration object.</p>
  173. See <a href="http://www.erlang.org/doc/man/ets.html#last-1" target="_top"><tt>http://www.erlang.org/doc/man/ets.html#last-1</tt></a>.
  174. The registry behaves as an ordered_set table.</p>
  175. <h3 class="function"><a name="lookup_global_aggr_counter-1">lookup_global_aggr_counter/1</a></h3>
  176. <div class="spec">
  177. <p><tt>lookup_global_aggr_counter(Name::any()) -&gt; integer()</tt></p>
  178. </div><p>Equivalent to <a href="#where-1"><tt>where({a, g, Name})</tt></a>.</p>
  179. <p>Lookup a global (unique) aggregated counter and returns its value.
  180. Fails if there is no such object.</p>
  181. <h3 class="function"><a name="lookup_global_counters-1">lookup_global_counters/1</a></h3>
  182. <div class="spec">
  183. <p><tt>lookup_global_counters(Counter::any()) -&gt; [{pid(), Value::integer()}]</tt></p>
  184. </div><p>Equivalent to <a href="#lookup_values-1"><tt>lookup_values({c, g, Counter})</tt></a>.</p>
  185. <p>Look up all global (non-unique) instances of a given Counter.
  186. Returns a list of {Pid, Value} tuples for all matching objects.</p>
  187. <h3 class="function"><a name="lookup_global_name-1">lookup_global_name/1</a></h3>
  188. <div class="spec">
  189. <p><tt>lookup_global_name(Name::any()) -&gt; pid()</tt></p>
  190. </div><p>Equivalent to <a href="#where-1"><tt>where({n, g, Name})</tt></a>.</p>
  191. <p>Lookup a global unique name. Fails if there is no such name.</p>
  192. <h3 class="function"><a name="lookup_global_properties-1">lookup_global_properties/1</a></h3>
  193. <div class="spec">
  194. <p><tt>lookup_global_properties(Property::any()) -&gt; [{pid(), Value}]</tt></p>
  195. </div><p>Equivalent to <a href="#lookup_values-1"><tt>lookup_values({p, g, Property})</tt></a>.</p>
  196. <p>Look up all global (non-unique) instances of a given Property.
  197. Returns a list of {Pid, Value} tuples for all matching objects.</p>
  198. <h3 class="function"><a name="lookup_local_aggr_counter-1">lookup_local_aggr_counter/1</a></h3>
  199. <div class="spec">
  200. <p><tt>lookup_local_aggr_counter(Name::any()) -&gt; integer()</tt></p>
  201. </div><p>Equivalent to <a href="#where-1"><tt>where({a, l, Name})</tt></a>.</p>
  202. <p>Lookup a local (unique) aggregated counter and returns its value.
  203. Fails if there is no such object.</p>
  204. <h3 class="function"><a name="lookup_local_counters-1">lookup_local_counters/1</a></h3>
  205. <div class="spec">
  206. <p><tt>lookup_local_counters(Counter::any()) -&gt; [{pid(), Value::integer()}]</tt></p>
  207. </div><p>Equivalent to <a href="#lookup_values-1"><tt>lookup_values({c, l, Counter})</tt></a>.</p>
  208. <p>Look up all local (non-unique) instances of a given Counter.
  209. Returns a list of {Pid, Value} tuples for all matching objects.</p>
  210. <h3 class="function"><a name="lookup_local_name-1">lookup_local_name/1</a></h3>
  211. <div class="spec">
  212. <p><tt>lookup_local_name(Name::any()) -&gt; pid()</tt></p>
  213. </div><p>Equivalent to <a href="#where-1"><tt>where({n, l, Name})</tt></a>.</p>
  214. <p>Lookup a local unique name. Fails if there is no such name.</p>
  215. <h3 class="function"><a name="lookup_local_properties-1">lookup_local_properties/1</a></h3>
  216. <div class="spec">
  217. <p><tt>lookup_local_properties(Property::any()) -&gt; [{pid(), Value}]</tt></p>
  218. </div><p>Equivalent to <a href="#lookup_values-1"><tt>lookup_values({p, l, Property})</tt></a>.</p>
  219. <p>Look up all local (non-unique) instances of a given Property.
  220. Returns a list of {Pid, Value} tuples for all matching objects.</p>
  221. <h3 class="function"><a name="lookup_pid-1">lookup_pid/1</a></h3>
  222. <div class="spec">
  223. <p><tt>lookup_pid(Key) -&gt; Pid</tt></p>
  224. </div><p>Lookup the Pid stored with a key.
  225. </p>
  226. <h3 class="function"><a name="lookup_pids-1">lookup_pids/1</a></h3>
  227. <div class="spec">
  228. <p><tt>lookup_pids(Key::<a href="#type-key">key()</a>) -&gt; [pid()]</tt></p>
  229. </div><p><p>Returns a list of pids with the published key Key</p>
  230. If the type of registration entry is either name or aggregated counter,
  231. this function will return either an empty list, or a list of one pid.
  232. For non-unique types, the return value can be a list of any length.</p>
  233. <h3 class="function"><a name="lookup_values-1">lookup_values/1</a></h3>
  234. <div class="spec">
  235. <p><tt>lookup_values(Key::<a href="#type-key">key()</a>) -&gt; [{pid(), Value}]</tt></p>
  236. </div><p><p>Retrieve the <code>{Pid,Value}</code> pairs corresponding to Key.</p>
  237. Key refer to any type of registry object. If it refers to a unique
  238. object, the list will be of length 0 or 1. If it refers to a non-unique
  239. object, the return value can be a list of any length.</p>
  240. <h3 class="function"><a name="mreg-3">mreg/3</a></h3>
  241. <div class="spec">
  242. <p><tt>mreg(T::<a href="#type-type">type()</a>, X2::<a href="#type-scope">scope()</a>, KVL::[{Key::any(), Value::any()}]) -&gt; true</tt></p>
  243. </div><p><p>Register multiple {Key,Value} pairs of a given type and scope.</p>
  244. This function is more efficient than calling <a href="#reg-2"><code>reg/2</code></a> repeatedly.</p>
  245. <h3 class="function"><a name="nb_wait-1">nb_wait/1</a></h3>
  246. <div class="spec">
  247. <p><tt>nb_wait(Key::<a href="#type-key">key()</a>) -&gt; Ref</tt></p>
  248. </div><p>Wait for a local name to be registered.
  249. The caller can expect to receive a message,
  250. {gproc, Ref, registered, {Key, Pid, Value}}, once the name is registered.</p>
  251. <h3 class="function"><a name="next-2">next/2</a></h3>
  252. <div class="spec">
  253. <p><tt>next(Context::<a href="#type-context">context()</a>, Key::<a href="#type-key">key()</a>) -&gt; <a href="#type-key">key()</a> | '$end_of_table'</tt></p>
  254. </div><p><p>Behaves as ets:next(Tab,Key) for a given type of registration object.</p>
  255. See <a href="http://www.erlang.org/doc/man/ets.html#next-2" target="_top"><tt>http://www.erlang.org/doc/man/ets.html#next-2</tt></a>.
  256. The registry behaves as an ordered_set table.</p>
  257. <h3 class="function"><a name="prev-2">prev/2</a></h3>
  258. <div class="spec">
  259. <p><tt>prev(Context::<a href="#type-context">context()</a>, Key::<a href="#type-key">key()</a>) -&gt; <a href="#type-key">key()</a> | '$end_of_table'</tt></p>
  260. </div><p><p>Behaves as ets:prev(Tab,Key) for a given type of registration object.</p>
  261. See <a href="http://www.erlang.org/doc/man/ets.html#prev-2" target="_top"><tt>http://www.erlang.org/doc/man/ets.html#prev-2</tt></a>.
  262. The registry behaves as an ordered_set table.</p>
  263. <h3 class="function"><a name="reg-1">reg/1</a></h3>
  264. <div class="spec">
  265. <p><tt>reg(Key::<a href="#type-key">key()</a>) -&gt; true</tt></p>
  266. </div><p>Equivalent to <a href="#reg-2"><tt>reg(Key, default(Key))</tt></a>.</p>
  267. <h3 class="function"><a name="reg-2">reg/2</a></h3>
  268. <div class="spec">
  269. <p><tt>reg(Key::<a href="#type-key">key()</a>, Value) -&gt; true</tt></p>
  270. </div><p><p>Register a name or property for the current process</p>
  271. </p>
  272. <h3 class="function"><a name="select-1">select/1</a></h3>
  273. <div class="spec">
  274. <p><tt>select(Pat::<a href="#type-select_pattern">select_pattern()</a>) -&gt; list(<a href="#type-sel_object">sel_object()</a>)</tt></p>
  275. </div><p>Equivalent to <a href="#select-2"><tt>select(all, Pat)</tt></a>.</p>
  276. <h3 class="function"><a name="select-2">select/2</a></h3>
  277. <div class="spec">
  278. <p><tt>select(Type::<a href="#type-sel_type">sel_type()</a>, Pat::<a href="#type-sel_pattern">sel_pattern()</a>) -&gt; [{Key, Pid, Value}]</tt></p>
  279. </div><p><p>Perform a select operation on the process registry.</p>
  280. The physical representation in the registry may differ from the above,
  281. but the select patterns are transformed appropriately.</p>
  282. <h3 class="function"><a name="select-3">select/3</a></h3>
  283. <div class="spec">
  284. <p><tt>select(Type::<a href="#type-sel_type">sel_type()</a>, Pat::<a href="#type-sel_patten">sel_patten()</a>, Limit::integer()) -&gt; [{Key, Pid, Value}]</tt></p>
  285. </div><p><p>Like <a href="#select-2"><code>select/2</code></a> but returns Limit objects at a time.</p>
  286. See <a href="http://www.erlang.org/doc/man/ets.html#select-3" target="_top"><tt>http://www.erlang.org/doc/man/ets.html#select-3</tt></a>.</p>
  287. <h3 class="function"><a name="send-2">send/2</a></h3>
  288. <div class="spec">
  289. <p><tt>send(Key::<a href="#type-key">key()</a>, Msg::any()) -&gt; Msg</tt></p>
  290. </div><p><p>Sends a message to the process, or processes, corresponding to Key.</p>
  291. If Key belongs to a unique object (name or aggregated counter), this
  292. function will send a message to the corresponding process, or fail if there
  293. is no such process. If Key is for a non-unique object type (counter or
  294. property), Msg will be send to all processes that have such an object.</p>
  295. <h3 class="function"><a name="set_value-2">set_value/2</a></h3>
  296. <div class="spec">
  297. <p><tt>set_value(Key::<a href="#type-key">key()</a>, Value) -&gt; true</tt></p>
  298. </div><p><p>Sets the value of the registeration entry given by Key</p>
  299. <p>Key is assumed to exist and belong to the calling process.
  300. If it doesn't, this function will exit.</p>
  301. Value can be any term, unless the object is a counter, in which case
  302. it must be an integer.</p>
  303. <h3 class="function"><a name="start_link-0">start_link/0</a></h3>
  304. <div class="spec">
  305. <p><tt>start_link() -&gt; {ok, pid()}</tt></p>
  306. </div><p><p>Starts the gproc server.</p>
  307. This function is intended to be called from gproc_sup, as part of
  308. starting the gproc application.</p>
  309. <h3 class="function"><a name="table-1">table/1</a></h3>
  310. <div class="spec">
  311. <p><tt>table(Context::<a href="#type-context">context()</a>) -&gt; any()</tt></p>
  312. </div><p>Equivalent to <a href="#table-2"><tt>table(Context, [])</tt></a>.</p>
  313. <h3 class="function"><a name="table-2">table/2</a></h3>
  314. <div class="spec">
  315. <p><tt>table(Context::<a href="#type-context">context()</a>, Opts) -&gt; any()</tt></p>
  316. </div><p>QLC table generator for the gproc registry.
  317. Context specifies which subset of the registry should be queried.
  318. See <a href="http://www.erlang.org/doc/man/qlc.html" target="_top"><tt>http://www.erlang.org/doc/man/qlc.html</tt></a>.</p>
  319. <h3 class="function"><a name="unreg-1">unreg/1</a></h3>
  320. <div class="spec">
  321. <p><tt>unreg(Key::<a href="#type-key">key()</a>) -&gt; true</tt></p>
  322. </div><p>Unregister a name or property.</p>
  323. <h3 class="function"><a name="update_counter-2">update_counter/2</a></h3>
  324. <div class="spec">
  325. <p><tt>update_counter(Key::<a href="#type-key">key()</a>, Incr::integer()) -&gt; integer()</tt></p>
  326. </div><p><p>Updates the counter registered as Key for the current process.</p>
  327. This function works like ets:update_counter/3
  328. (see <a href="http://www.erlang.org/doc/man/ets.html#update_counter-3" target="_top"><tt>http://www.erlang.org/doc/man/ets.html#update_counter-3</tt></a>), but
  329. will fail if the type of object referred to by Key is not a counter.</p>
  330. <h3 class="function"><a name="where-1">where/1</a></h3>
  331. <div class="spec">
  332. <p><tt>where(Key::<a href="#type-key">key()</a>) -&gt; pid()</tt></p>
  333. </div><p><p>Returns the pid registered as Key</p>
  334. The type of registration entry must be either name or aggregated counter.
  335. Otherwise this function will exit. Use <a href="#lookup_pids-1"><code>lookup_pids/1</code></a> in these
  336. cases.</p>
  337. <hr>
  338. <div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  339. <p><i>Generated by EDoc, Feb 11 2010, 05:33:39.</i></p>
  340. </body>
  341. </html>