scalaz/scalaz — pull request #408 by plokhotnyuk (2013-06-25 22:55:35+00:00)
Title: add alternative implementation of thread pool with fixed number of threads and strategy that optimized for actors

...and with minor improvements of imports, docs & test title.

Inspired by 'Mechanical Sympathy' posts of Martin Thompson, MPSC node bases queue described by Dmitry Vyukov and using of a semaphore to control access to shared queue implemented by Bill La Forge in `ThreadManagerImpl` from his JActor2 project, in `FixedThreadPoolExecutor` I minimized usage of CPU time and latency between submission of task and starting of it execution, compared with well known `ThreadPoolExecutor` and `ForkJoinPool` from `java.util.concurrent`.

Please see results of actor benchmarks for different actor libraries that uses different implementation of `ExecutionService` interface:
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out0_poolSize1.txt
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out0_poolSize10.txt
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out0_poolSize100.txt
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out0_poolSize1000.txt
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out1_poolSize1.txt
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out1_poolSize10.txt
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out1_poolSize100.txt
https://github.com/plokhotnyuk/actors/blob/81a3308d6f39b3a6429c4933b2156d5ac0c0a1f4/out1_poolSize1000.txt

I would like to thanks all of you, who try and use it.

It is was cooked at kitchen of actor benchmarks: https://github.com/plokhotnyuk/actors and if it doesn't contradict with Scalaz conventions, I would like to preserve link to it in docs to simplify of picking it up by you to improve/maintain `Actor`, `FixedThreadPoolExecutor` and Strategy from `scalaz.concurrent` in future.

Special thanks to amazing people inspired me and helped me with testing, reviewing and bug fixing of this code: Alex Levan, Bill La Forge, Dmitry Vyukov, George Leontiev, Martin Thompson, Sergiy Onenko, Viktor Klang, Yaroslav Klymko.

Some ideas like using of MPSC node based queue for message queue for actors encouraged @viktorklang to implement akka.dispatch.SingleConsumerOnlyUnboundedMailbox, than his implementation encouraged me to port a fix of potentially memory leak that was resolved in his code: https://github.com/scalaz/scalaz/pull/396

Also very special thanks to my wife, Elena, who’s been the main source of inspiration to me all this time.