<div dir="ltr"><div><br></div><div><br></div><div>Hello, I'm giving a course in distributed and parallel programming in</div><div>Erlang ...</div><div><br></div><div>Next week I'll be talking about common concurrency patterns, I was</div>
<div>talking with the course adviser, and I rattled off the names of a few</div><div>concurrency patterns that were well-known and easy to explain. I said</div><div>I'll do PUB-SUB, pipeline, map-reduce, parallel map, and so on.</div>
<div><br></div><div>At this stage the course adviser said that a) things like PUB-SUB</div><div>would not be familiar to the students and that b) It would take more</div><div>than 5-10 minutes to explain PUB_SUB.</div><div>
<br></div><div>At this stage I thought "pity these patterns don't have well-known</div><div>names".</div><div><br></div><div>What I'd like is to make a catalog of "well-known" concurrency</div>
<div>patterns. I'd like to name them, and describe them informally, and</div><div>give the example code in Erlang.</div><div><br></div><div>For example, here's how I might describe PUB-SUB.</div><div> </div><div>
== PUB-SUB</div><div><br></div><div> - There are a number of named channels</div><div> - You can post messages to a channel ie Publish the message (the PUB)</div><div> - You can subscribe to a channel (The SUB)</div>
<div> - If you are currently subscribed to a channel you will be sent all messages</div><div> sent to the channel.</div><div><br></div><div>A rudimentary version of this is about 25 lines of Erlang. A full</div><div>
version with load balancing, removing bottlenecks etc. would be a lot</div><div>longer, but that's not the point. The basic concurrent structure can</div><div>be explained in a few lines and named.</div><div><br></div>
<div><br></div><div>Pipeline is another example: The output of the first process is the</div><div>input to the next process and so on...</div><div><br></div><div>Now I start having problems.</div><div><br></div><div>Suppose I want to generalize a regular map. </div>
<div><br></div><div>To be precise. Suppose map(F, L) means [F(I) || I <- L]</div><div><br></div><div>pmap(F, L) is parallel map (easy) all the F(I)'s are computed concurrently.</div><div><br></div><div>pmap(F, L, Max) behaves like map(F,L) with at most Max F(I)'s computed concurrently.</div>
<div><br></div><div>What should this be called? "Pool of workers"</div><div><br></div><div>There seem to be things with well-known names "Load-balancer" "map-reduce" etc.</div><div><br></div>
<div>Then there are things that we know of but that are not named. For</div><div>example my DNS resolver has two DNS names DNS1 and DNS2. If DNS1 is</div><div>broken the resolver tries DNS2 - what is concurrency pattern called</div>
<div>(Pool of responders) or what?</div><div><br></div><div>The other day I suggested that for fault tolerance it was much easier</div><div>to let the client go to multiple machines rather than use an expensive</div><div>
load balancer and fail-over system on the server - but there was no</div><div>convenient name to capture this idea.</div><div><br></div><div>There sees to be no accepted terminology here - so I'd appreciate any</div><div>
suggestions you have as to the names of common currency patterns that</div><div>you use together with definitions of what the names mean.</div><div><br></div><div>Cheers</div><div><br></div><div>/Joe</div><div><br></div></div>