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