[erlang-questions] Question about message passing paradigm

Hynek Vychodil <>
Mon Jun 30 10:49:32 CEST 2008

Change your design from pull to push. Make servers which collect data and do
something instead "request" data or actions.

2008/6/29 Mike T <>:

> Hello,
> I was not sure where best to post this and hope someone is able to
> help with this question.
> After being bitten by the pitfalls of lock-oriented multi threading I
> am interested in switching to message passing oriented concurrency.
> I have read that erlang has a per-process ordering guarantee (that is
> if A sends messages 1 and 2 to B 1 will arrive before 2 at B. However,
> there is no guarantee that messages from C and D will not be placed in
> between 1 and 2.
> So my question is this:
> In my current lock oriented program design I have threads dedicated to
> managing different collections and actions on those collections
> (hashmaps), lets call them A, B, C, and D. At several points in the
> program one thread needs to get data from the other collections and
> make a decision based on the collective state of the values it gathers
> form those other collections.
> An example situation would be A needing data from B, C, and D. In that
> case A would attempt to lock A, B, C, and D then gather the items it
> needs and release the lock.
> How would I accomplish this same task in a message passing manner?
> I had though of doing: A sends a message to B, C, and D asking for the
> data. However, B, C, and D may have each changed independently of each
> other by the time they receive the request for data and/or by the time
> they are able to send the message to A. So, how do you deal with
> situations like this in a message passing paradigm?
> _______________________________________________
> erlang-questions mailing list
> http://www.erlang.org/mailman/listinfo/erlang-questions

--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080630/90eaef54/attachment.html>

More information about the erlang-questions mailing list