[erlang-questions] Question about message passing paradigm

Tom Ayerst tom.ayerst@REDACTED
Sun Jun 29 13:16:34 CEST 2008


Hi Mike,

To go off on a slight tangent with the hope of understanding your problem
better, do you have to get the data from the other collections with them
locked?  Can you just ask for their current state and use whatever they have
at that point or are they somehow dependent on each other?

Tom

2008/6/29 Mike T <talmage.news@REDACTED>:

> 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
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080629/93db61d1/attachment.htm>


More information about the erlang-questions mailing list