<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Yes, this is correct.</div><div><br></div><div>Gproc supports a few different types of register entries:</div><div><br></div><div>- names, which are unique (can be any term)</div><div>- properties, which can be held by multiple processes simultaneously</div><div>- counters, which are properties with update_counter() semantics</div><div>- aggregate counters, which maintain the sum of all counters with</div><div>  the same name as the aggregate counter.</div><div><br></div><div>Properties are very useful for pub-sub, but also for highlighting various characteristics of the process. In my initial presentation of gproc, I had integrated it into OTP and modified the behaviors to register a {p,l,{behaviour,B}} property. This way, you could easily query the system for a certain type of behavior, and drill further to inspect other things.</div><div><br></div><div>(This had the unfortunate side-effect that many thought you had to have a patched OTP to use gproc. Next time, I will try to be smarter).</div><div><br></div><div>Thus, if you inspect a process, either with gproc:i(), or gproc:info(Pid [, gproc]), you can easily tell from its registered names and properties quite a bit about the process.</div><div><br></div><div>BTW, I've been thinking about adding a function, gproc:bcast(Key, Msg), which would be similar to:</div><div><br></div><div>rpc:abcast(gproc, send, [Key, Msg])</div><div><br></div><div>but with more predictable sequencing behavior, most likely making use of a gproc_bcast server to make sure all messages go the same way.</div><div><br></div><div>Wild cheers and enthusiasm may intice me to do it sooner rather than later…. ;-)</div><div><br></div><div>BR,</div><div>Ulf W</div><br><div><div>On 6 Jun 2012, at 14:50, Eric Moritz wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p>Yes, if you register a property key, you can retrieve all the procs that have that property set.  For instance a fanout pub/sub can be accomplished doing:</p><p>subscribe(Channel) -><br>
    gproc:reg({p, l, {subscribers,<br>
                               Channel}}).</p><p>publish(Channel, Msg) -><br>
    gproc:send({p, l, {subscribers,<br>
                                  Channel}},<br>
                         Msg).</p><p>If a process calls publish/2, the message will be sent to every process that called subscribe/1.</p><p>I'm on my phone so it's a bit hard to look up the details, if you want to get a list of pids that called subscribe, look at the code of gproc:send/2.  I think the function is called lookup_pids/1 but I may be wrong.</p><p>The etorrent project uses gproc.  That's a good read if you want to see how to use gproc.  He uses property keys for each torrent file process as well as using await to delay initialization of gen_servers that depend on other gen_servers.<br>
</p><p>Eric Moritz.<br>
</p>
<div class="gmail_quote">On Jun 6, 2012 8:27 AM, "Loïc Hoguin" <<a href="mailto:essen@ninenines.eu">essen@ninenines.eu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 05/26/2012 10:38 PM, Motiejus Jakštys wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
</blockquote>
<br>
Hello,<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For term() to pid() mapping I've always used gproc. For the same thing<br>
my coworker always used pg2.<br>
<br>
I am making a comparison now. There are some features in gproc which are<br>
not in pg2:<br>
<br>
* Await for registration<br>
* Per-process properties<br>
* Aggregate counters<br>
* QLC<br>
<br>
Whereas pg2 "natively" supports mapping one key to several processes<br>
(which can be easily achieved with QLC in gproc).<br>
</blockquote>
<br>
Unless I misunderstand, gproc's properties are exactly this, mapping one key to several processes.<br>
<br>
-- <br>
Loïc Hoguin<br>
Erlang Cowboy<br>
Nine Nines<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote></div>
_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><div>Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.</div><div><a href="http://feuerlabs.com">http://feuerlabs.com</a></div></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>