[erlang-questions] gproc Help

Andrew Berman rexxe98@REDACTED
Fri Jun 22 23:19:28 CEST 2012

I'm trying to use gproc as a very basic pub/sub.  Here is example code I
have (very basic):



new() ->
    Pid = spawn_link(?MODULE, apply, []),
    gproc_ps:subscribe(l, test),

apply() ->
        {gproc_ps_event, test, Msg} -> io:put_chars(Msg),

publish() ->
    gproc_ps:publish(l, test, "My test message").

In the shell I then do:

Pid = test:new().

My expectation was that I would get an output of "My test message", but all
I get is {gproc_ps_event,test,"My test message"}.  When I do a flush(), I
do get the Shell got {gproc_ps_event,test,"My test message"}.  What am I
doing wrong?  I obviously don't understand something, can someone explain
how to get this simple example to work.  I know I can do Pid ! {....} in
this example, but I'm trying to play with gproc.

Thanks for any help!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120622/2578b40f/attachment.htm>

More information about the erlang-questions mailing list