Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
For testing purposes, the easiest way to go is jitpack:
resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.User" % "Repo" % "Tag"| // Define the general Arg type and companion object: | |
| import language.higherKinds, language.implicitConversions, language.existentials | |
| object Arg { implicit def toArg[Tc[_], T: Tc](t: T): Arg[T, Tc] = Arg(t, implicitly[Tc[T]]) } | |
| case class Arg[T, Tc[_]](value: T, typeclass: Tc[T]) | |
| // Say, for example we have a typeclass for getting the length of something, with a few instances | |
| trait Lengthable[T] { def length(t: T): Int } | |
| implicit val intLength = new Lengthable[Int] { def length(i: Int) = 1 } | |
| implicit val stringLength = new Lengthable[String] { def length(s: String) = s.length } |