mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-13 06:38:52 +02:00
ef4c5eb65e
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
28 lines
847 B
Scala
28 lines
847 B
Scala
package com.twitter.simclustersann.modules
|
|
|
|
import com.google.inject.Provides
|
|
import com.twitter.inject.TwitterModule
|
|
import com.twitter.inject.annotations.Flag
|
|
import com.twitter.simclustersann.common.FlagNames.NumberOfThreads
|
|
import com.twitter.util.ExecutorServiceFuturePool
|
|
import java.util.concurrent.Executors
|
|
import javax.inject.Singleton
|
|
object FuturePoolProvider extends TwitterModule {
|
|
flag[Int](
|
|
name = NumberOfThreads,
|
|
default = 20,
|
|
help = "The number of threads in the future pool."
|
|
)
|
|
|
|
@Singleton
|
|
@Provides
|
|
def providesFuturePool(
|
|
@Flag(NumberOfThreads) numberOfThreads: Int
|
|
): ExecutorServiceFuturePool = {
|
|
val threadPool = Executors.newFixedThreadPool(numberOfThreads)
|
|
new ExecutorServiceFuturePool(threadPool) {
|
|
override def toString: String = s"warmup-future-pool-$executor)"
|
|
}
|
|
}
|
|
}
|