the-algorithm/simclusters-ann/server/src/main/scala/com/twitter/simclustersann/modules/FuturePoolProvider.scala
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
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.
2023-03-31 17:36:31 -05:00

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)"
}
}
}