proc added to jungerl

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Mon Mar 6 17:31:31 CET 2006


I added an application called 'proc'
to jungerl.

It's a development based on proc_reg, but
sufficiently different that I wanted to 
rename it.

The idea:

- 'proc' is a local process registry
- proc:reg(Name) registers a unique name (any term)
- proc:add_property(Property) registers
  a property (any term)
- proc:fold_names(Fun, Acc, SelectPatterns)
  allows you to operate on a group of named 
  processes. The fun takes ({Name,Pid},Acc)
- proc:fold_properties(...) similar function
  for folding over properties.

For example:

proc:fold_properties(
  fun({_,Pid},Acc) ->
    [{Pid|sys:get_status(Pid)}|Acc]
  end, [], [{h248_link_handler,[],[true]}])

would select all processes that have registered
themselves as h248 link handler processes, and
return the result of sys:get_status(Pid) on each.

Another use of this is publish/subscribe.
A subscribe() function could add a property
to the current process, and notify() could 
fold over the property and send a message to 
each subscriber. Each registered process is 
automatically monitored, of course, and 
removed from the index if it dies.

Those are the key functions. There are many
other small utility functions. Essentially,
proc becomes an index with which to find 
processes, by publishing known characteristics
of each process.

One of the ideas behind proc is to have a 
way to keep track of processes in very large
systems (100s of thousand processes).
proc:i/1 works like the i() function, but 
takes a filter (select patterns on names or
properties) defining which processes to include
or exclude from the listing.

/Ulf W



More information about the erlang-questions mailing list