Add AffinityPool which pins actors to threads (#23104)

This commit is contained in:
Zahari Dichev 2017-07-07 14:36:26 +03:00 committed by Patrik Nordwall
parent fe2bf91659
commit 4d45064296
14 changed files with 1345 additions and 139 deletions

View file

@ -92,6 +92,28 @@ object DispatcherDocSpec {
}
//#my-thread-pool-dispatcher-config
//#affinity-pool-dispatcher-config
affinity-pool-dispatcher {
# Dispatcher is the name of the event-based dispatcher
type = Dispatcher
# What kind of ExecutionService to use
executor = "affinity-pool-executor"
# Configuration for the thread pool
affinity-pool-executor {
# Min number of threads to cap factor-based parallelism number to
parallelism-min = 8
# Parallelism (threads) ... ceil(available processors * factor)
parallelism-factor = 1
# Max number of threads to cap factor-based parallelism number to
parallelism-max = 16
}
# Throughput defines the maximum number of messages to be
# processed per actor before the thread jumps to the next actor.
# Set to 1 for as fair as possible.
throughput = 100
}
//#affinity-pool-dispatcher-config
//#fixed-pool-size-dispatcher-config
blocking-io-dispatcher {
type = Dispatcher
@ -294,6 +316,14 @@ class DispatcherDocSpec extends AkkaSpec(DispatcherDocSpec.config) {
//#defining-pinned-dispatcher
}
"defining affinity-pool dispatcher" in {
val context = system
//#defining-affinity-pool-dispatcher
val myActor =
context.actorOf(Props[MyActor].withDispatcher("affinity-pool-dispatcher"), "myactor4")
//#defining-affinity-pool-dispatcher
}
"looking up a dispatcher" in {
//#lookup
// for use with Futures, Scheduler, etc.