logo       

Scala paper: Actors that Unify Threads and Events: msg#00481

lang.scala

Subject: Scala paper: Actors that Unify Threads and Events

Dear list,

Martin and I have finished a new report on Scala's actors.

As the title suggests it's mostly about our unified programming model
that allows an actor to suspend by blocking a thread (`receive'), as
well as by saving a continuation closure (`react'). The latter method
allows to detach the suspending actor from its worker thread making it
possible to re-use the worker thread for the execution of other actors
(the principle introduced in the event-based actors paper, see
http://lamp.epfl.ch/~phaller/doc/haller06jmlc.pdf).

In the unified model, actors may call any operation applicable to normal
Java threads (such as `wait()' or `notify()'). Conversely, Java threads
are treated like actors. That is, they may send and receive messages
just like normal actors (the actor identity of a thread is obtained
using `self' as usual).

Sequential composition is now supported with the `andThen' and `loop'
combinators. In particular, if some block of code ends in a `react'
(which has return type `Nothing', i.e. it never returns), you can avoid
passing an explicit continuation by using `andThen':

{ ...; react { case A => ... } } andThen { ... }

Typical event-loops can be written using `loop':
loop {
react {
case A => ...
case B => ...
}
}

In addition to the technical sections, the paper provides an up-to-date
introduction to the current Scala actors library. We also show some
experimental results, comparing to Java threads, SALSA and Doug Lea's
FJ, both on single-core and multi-core machines.

You find the full text, BibTex etc. at:
http://infoscience.epfl.ch/search.py?recid=99729&ln=en
(if you have problems with the above link, you also find it on my home
page: http://lamp.epfl.ch/~phaller/doc/haller07actorsunify.pdf)

At the bottom of this mail you find an abstract.

Feedback is very welcome!

Philipp


Abstract:

In practice, concurrent programming systems based on message passing
are often instantiations of the actor model. A popular implementation
of this form of concurrency is the Erlang programming language. Erlang
supports massively concurrent systems such as telephone exchanges by
providing very lightweight concurrent processes.

On mainstream platforms such as the JVM, an equally attractive
implementation was as yet missing. Their standard concurrency
constructs, shared-memory threads with locks, suffer from high
initialization and context-switching overhead as well as high memory
consumption. Therefore, the interleaving of independent computations
is often modelled in an event-driven style on these
platforms. However, programming in an explicitly event-driven style is
complicated and error-prone, because it involves an inversion of
control.

In this paper we present an abstraction of actors that combines the
benefits of thread-based and event-based concurrency. Threads support
blocking operations such as system I/O, and can be executed on
multiple processor cores in parallel. Event-based computation, on the
other hand, is more lightweight and scales to large numbers of actors.
We also present a set of combinators that allows a flexible
composition of these actors.





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise