mirror https://github.com/uwiger/gproc

Ulf Wiger 9c505d47a1 eunit tests for get_env/4 et al 14 years ago
doc c306076df2 First implementation of environment variable handling. 14 years ago
include 9d5340e024 fixes noted by @jlouis, first eunit suite, bug fixes around mreg 14 years ago
patches d0bc9d2409 restructuring 16 years ago
priv 42a9f405be minor directory cleanup 15 years ago
reference 98ba2d9bfa added rebar support 14 years ago
src 9c505d47a1 eunit tests for get_env/4 et al 14 years ago
test 9c505d47a1 eunit tests for get_env/4 et al 14 years ago
.gitignore 96dc093acb Add deps 14 years ago
Makefile 95a6320b65 added 'doc' target to Makefile 14 years ago
README.md 9c505d47a1 eunit tests for get_env/4 et al 14 years ago
rebar 59365c4bef Fixed select/qlc scope (default: all); fixed dist eunit test; new rebar 14 years ago
rebar.config 2393bf45ee Added gproc:give_away/2 and introduced eunit tests for gproc_dist 14 years ago

README.md

The gproc application

The gproc application

Extended process dictionary.

Authors: Ulf Wiger (ulf.wiger@erlang-solutions.com), Joseph Wayne Norton (norton@geminimobile.com).

Extended process dictionary

Introduction

Gproc is a process dictionary for Erlang, which provides a number of useful features beyond what the built-in dictionary has:

  • Use any term as a process alias

  • Register a process under several aliases

  • Non-unique properties can be registered simultaneously by many processes

  • QLC and match specification interface for efficient queries on the dictionary

  • Await registration, let's you wait until a process registers itself

  • Atomically give away registered names and properties to another process

  • Counters, and aggregated counters, which automatically maintain the total of all counters with a given name

  • Global registry, with all the above functions applied to a network of nodes

An interesting application of gproc is building publish/subscribe patterns. Example:

subscribe(EventType) ->
    %% Gproc notation: {p, l, Name} means {(p)roperty, (l)ocal, Name}
    gproc:reg({p, l, {?MODULE, EventType}}).

notify(EventType, Msg) ->
    Key = {?MODULE, EventType},
    gproc:send({p, l, Key}, {self(), Key, Msg}).

Gproc has a QuickCheck test suite, covering a fairly large part of the local gproc functionality, although none of the global registry. It requires a commercial EQC license, but rebar is smart enough to detect whether EQC is available, and if it isn't, the code in gproc_eqc.erl will be "defined away".

There is also an eunit suite, covering the basic operations for local and global gproc.

Building Edoc

By default, ./rebar doc generates Github-flavored Markdown files.If you want to change this, remove the edoc_opts line from rebar.config.

Gproc was first introduced at the ACM SIGPLAN Erlang Workshop in Freiburg 2007 (Paper available here).

Modules

gproc
gproc_app
gproc_dist
gproc_init
gproc_lib
gproc_sup