All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.finagle.netty3.package.scala Maven / Gradle / Ivy

There is a newer version: 7.0.0
Show newest version
package com.twitter.finagle

import com.twitter.concurrent.NamedPoolThreadFactory
import com.twitter.finagle.util.ProxyThreadFactory
import com.twitter.util.Awaitable
import java.util.concurrent.{ExecutorService, Executors}
import org.jboss.netty.channel.socket.nio.NioWorkerPool
import org.jboss.netty.util.{ThreadNameDeterminer, ThreadRenamingRunnable}

/**
 * Package netty3 implements the bottom finagle primitives:
 * {{com.twitter.finagle.Server}} and a client transport in terms of
 * the netty3 event loop.
 *
 * Note: when {{com.twitter.finagle.builder.ClientBuilder}} and
 * {{com.twitter.finagle.builder.ServerBuilder}} are deprecated,
 * package netty3 can move into its own package, so that only the
 * (new-style) clients and servers that depend on netty3 bring it in.
 */
package object netty3 {
  // Disable Netty's thread name rewriting, to preserve the "finagle/netty3"
  // suffix specified below.
  ThreadRenamingRunnable.setThreadNameDeterminer(ThreadNameDeterminer.CURRENT)

  val Executor: ExecutorService = {
    val threadFactory = new ProxyThreadFactory(
      new NamedPoolThreadFactory("finagle/netty3", makeDaemons = true),
      ProxyThreadFactory.newProxiedRunnable(
        () => Awaitable.enableBlockingTimeTracking(),
        () => Awaitable.disableBlockingTimeTracking()
      )
    )
    Executors.newCachedThreadPool(threadFactory)
  }

  private[netty3] val WorkerPool: NioWorkerPool = new NioWorkerPool(Executor, numWorkers())
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy