[concurrency-interest] Blocking vs. non-blocking
alexei.kaigorodov at gmail.com
Mon Jun 16 23:44:39 EDT 2014
Dennis Sosnoski <dms <at> sosnoski.com> writes:
> Hmmm. Now that I think about it, I've been telling people that
> there are just two fundamental ways of handling the completions of
> asynchronous events, with blocking waits or with callbacks. I
> suppose message passing could be considered a third way, even
> though it's kind of a variation of callbacks. Are there other ways
> that different significantly from these two (or three)?
> - Dennis
The two fundamental ways are threads with blocking waits and dataflow actors
with multiple input ports. Ports accept tokens (messages or signals), and
actor fires when the firing rule is satisfied. The typical firing rule is
"all inputs ready". Akka actors is a restricted implementation of general
dataflow actors: each actor has just 2 ports: one message port and one
signal port to prevent parallel execution of the same actor instance.
Callbacks are even more restricted: actor has only one message port for
callback parameters, leaving managing of parallelism to the user. As a
result, callbacks are not parallel-friendly. The art of asynchronous
programming is to chose the right actor implementation for the given task:
for some tasks callbacks are optimal, and for some tasks Akka is not enough.
More information about the Concurrency-interest