overview.edoc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. @author Ulf Wiger <ulf.wiger@erlang-solutions.com>
  2. @author Joseph Wayne Norton <norton@geminimobile.com>
  3. @doc Extended process dictionary
  4. == Introduction ==
  5. Gproc is a process dictionary for Erlang, which provides a number of useful features beyond what the built-in dictionary has:
  6. <ul>
  7. <li>Use any term as a process alias</li>
  8. <li>Register a process under several aliases</li>
  9. <li>Non-unique properties can be registered simultaneously by many processes</li>
  10. <li>QLC and match specification interface for efficient queries on the
  11. dictionary</li>
  12. <li>Await registration, let's you wait until a process registers itself</li>
  13. <li>Atomically give away registered names and properties to another process</li>
  14. <li>Counters, and aggregated counters, which automatically maintain the
  15. total of all counters with a given name</li>
  16. <li>Global registry, with all the above functions applied to a network of nodes</li>
  17. </ul>
  18. An interesting application of gproc is building publish/subscribe patterns.
  19. Example:
  20. <pre>
  21. subscribe(EventType) ->
  22. %% Gproc notation: {p, l, Name} means {(p)roperty, (l)ocal, Name}
  23. gproc:reg({p, l, {?MODULE, EventType}}).
  24. notify(EventType, Msg) ->
  25. Key = {?MODULE, EventType},
  26. gproc:send({p, l, Key}, {self(), Key, Msg}).
  27. </pre>
  28. Gproc has a QuickCheck test suite, covering a fairly large part of the local
  29. gproc functionality, although none of the global registry. It requires a
  30. commercial EQC license, but rebar is smart enough to detect whether EQC is
  31. available, and if it isn't, the code in gproc_eqc.erl will be "defined away".
  32. There is also an eunit suite, covering the basic operations for local and
  33. global gproc.
  34. == Building Edoc ==
  35. By default, `./rebar doc` generates Github-flavored Markdown files.
  36. If you want to change this, remove the `edoc_opts' line from `rebar.config'.
  37. Gproc was first introduced at the ACM SIGPLAN Erlang Workshop in
  38. Freiburg 2007 (<a href="erlang07-wiger.pdf">Paper available here</a>).
  39. @end