Message-ID: <141095180.4311.1369437242621.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_4310_70411411.1369437242620" ------=_Part_4310_70411411.1369437242620 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Dataflow concurrency offers an alternative concurrency model, wh= ich is inherently safe and robust.
Check out the small example written in Groovy using GPars, = which sums results of calculations performed by three concurrently run task= s:
We start three logical tasks, which can run in parallel and = perform their particular activities. The tasks need to exchange data and th= ey do so using Dataflow Variables. Think of Dataflow Varia= bles as one-shot channels safely and reliably tranferring data from produce= rs to their consumers.
The Dataflow Variables have a pretty straightf= orward semantics. When a task needs to read a value from DataflowVariab= le(through the val property), it will block until the value has been s= et by another taks or thread (using the '<<' operator). Each Data= flowVariable can be set only oncein its lifetime. Not= ice that you don't have to bother with ordering and synchronizing the tasks= or threads and their access to shared variables. The values are magically = transferred among tasks at the right time without your intervention. The da= ta flow seamlessly among tasks / threads without your intervention or care.=
Implementation detail: The three tasks in the examp= le do not necessarily need to be mapped to three physical threads= strong>. Tasks represent so-called "green" or "logical"= threads and can be mapped under the covers to any number of physical threa= ds. The actual mapping depends on the scheduler, but the outcome of dataflo= w algorithms doesn't depend on the actual scheduling.
Here's what you gain by using Dataflow Concurren= cy (by Jonas Bon=C3=A9r http://www.jonasboner.com ):
Th= is doesn't sound bad, does it?
If you'd like to know more on this int= eresting concept, check out the Dataflow concurr= ency section of the User Guide.
http://github.com= /jboner/scala-dataflow/tree/f9a38992f5abed4df0b12f6a5293f703aa04dc33/src Sc= ala Dataflow library by Jonas Bon=C3=A9r
http://jonasboner.com/talks/state_youre_doing_it_wrong/html/all.html JV= M concurrency presentation slides by Jonas Bon=C3=A9r
http://github.co= m/larrytheliquid/dataflow/tree/master Dataflow Concurrency library for Ruby=------=_Part_4310_70411411.1369437242620--