[erlang-questions] Question about message passing paradigm
Sun Jun 29 13:16:34 CEST 2008
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?
2008/6/29 Mike T <>:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions