ForkJoin and Akka Actors
2011-07-02 22:48:14 GMT
Ladies(?) and Gentlemen,
I recently (yesterday) attempted to create an Akka Actor Dispatcher using the Scala embedded version of the ForkJoin library, just wanted to verify that I'm doing the Right Thing™
Here's a link to the code: https://github.com/jboner/akka/blob/master/akka-actor/src/main/scala/akka/dispatch/FJDispatcher.scala
The design:
Since I'm just forking and never doing any joining, I've done "setAsyncMode(true)" on the ForkJoinPool.
Each Actors mailbox is a Runnable, and to avoid extra allocations I'm weaving in FJMailbox that wraps the mailbox as a ForkJoinTask so I can reuse it.
The mailbox is only available in the pool in a binary fashion (it's added to the pool when a message is added, if messages are added and it's already in the pool it just adds the message to the mailbox, and it's removed from the pool when the processing is completed).
If a mailbox is added to the pool, and it's done so by a ForkJoinWorkerThread, I use ForkJoinTask.fork(), and if not, I simply add it to the pool. (I always reinitialize it before doing so), here's the code for that: https://github.com/jboner/akka/blob/master/akka-actor/src/main/scala/akka/dispatch/FJDispatcher.scala#L73
At the end of processing a mailbox, it will, if it's done by a ForkJoinWorkerThread, it will call helpQuiesce() to make sure that things are getting processed. (It wasn't working until I found out I needed to call helpQuiesce)
Am I on the right track here?
Cheers,
√
--
Viktor Klang
Akka Tech Lead
_______________________________________________ Concurrency-interest mailing list Concurrency-interest <at> cs.oswego.edu http://cs.oswego.edu/mailman/listinfo/concurrency-interest
RSS Feed