val nestedFuture: Future[Future[Boolean]] = heatWater(Water(25)).map { water => temperatureOkay(water) } val flatFuture: Future[Boolean] = heatWater(Water(25)).flatMap { water => temperatureOkay(water) }
my-dispatcher { # Dispatcher is the name of the event-based dispatcher type= Dispatcher # What kind of ExecutionService to use executor = "fork-join-executor" # Configurationfor the fork join pool fork-join-executor { # Min number of threads to cap factor-based parallelism number to parallelism-min = 2 # Parallelism (threads) ... ceil(available processors * factor) parallelism-factor = 2.0 # Max number of threads to cap factor-based parallelism number to parallelism-max = 10 } # Throughput defines the maximum number of messages to be # processed per actor before the thread jumps to the next actor. # Set to 1for as fair as possible. throughput = 100 }
或者这样:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
my-thread-pool-dispatcher { # Dispatcher is the name of the event-based dispatcher type= Dispatcher # What kind of ExecutionService to use executor = "thread-pool-executor" # Configurationfor the thread pool thread-pool-executor { # minimum number of threads to cap factor-based core number to core-pool-size-min = 2 # No of core threads ... ceil(available processors * factor) core-pool-size-factor = 2.0 # maximum number of threads to cap factor-based number to core-pool-size-max = 10 } # Throughput defines the maximum number of messages to be # processed per actor before the thread jumps to the next actor. # Set to 1for as fair as possible. throughput = 100 }