Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package thoughtworks
    Definition Classes
    com
  • package raii
    Definition Classes
    thoughtworks
  • object AsynchronousPool extends Serializable

    The namespace that contains the implementation of the asynchronous resource pool.

    The namespace that contains the implementation of the asynchronous resource pool.

    Definition Classes
    raii
    Example:
    1. Given a factory that creates resources,

      import scalaz.Tags.Parallel
      import scalaz._
      import scalaz.syntax.tag._
      import scalaz.syntax.all._
      import com.thoughtworks.future._
      import com.thoughtworks.raii.asynchronous._
      import com.thoughtworks.raii.AsynchronousPool
      import java.lang.AutoCloseable
      
      trait MyResource extends AutoCloseable {
        def inUse(): Unit
      }
      
      val myResourceStub0 = stub[MyResource]
      val myResourceStub1 = stub[MyResource]
      val myResourceStub2 = stub[MyResource]
      
      val myResourceFactoryMock = mockFunction[MyResource]
      myResourceFactoryMock.expects().returns(myResourceStub0)
      myResourceFactoryMock.expects().returns(myResourceStub1)
      myResourceFactoryMock.expects().returns(myResourceStub2)

      then it can be converted to a resource pool, which holds some instances of MyResource.

      val myResourcePool: Do[Do[MyResource]] = AsynchronousPool.fixed(
        resourceFactory = Do.autoCloseable(myResourceFactoryMock()),
        poolSize = 3
      )

      When some clients are using the resource pool,

      def client(acquire: Do[MyResource], operationsPerClient: Int): Do[Unit] = {
        Do.nested[Unit](acquire.flatMap { myResource =>
          Do.execute {
              myResource.inUse
            }
            .replicateM_(operationsPerClient)
        })
      }
      def allClients(acquire: Do[MyResource], numberOfClients: Int, operationsPerClient: Int): ParallelDo[Unit] = {
        implicit def keepLastException = new Semigroup[Throwable] {
          override def append(f1: Throwable, f2: => Throwable) = f2
        }
        Applicative[ParallelDo].replicateM_(numberOfClients, Parallel(client(acquire, operationsPerClient)))
      }
      def usingPool(numberOfClients: Int, operationsPerClient: Int) = {
        myResourcePool.flatMap { acquire =>
          allClients(acquire, numberOfClients, operationsPerClient).unwrap
        }
      }

      then the operations from these clients should be distributed on those MyResources, and those MyResources should be closed after being used.

      usingPool(numberOfClients = 10, operationsPerClient = 10).run.map { _: Unit =>
        ((myResourceStub0.inUse _): () => Unit).verify().repeated(30 to 40)
        ((myResourceStub0.close _): () => Unit).verify().once()
      
        ((myResourceStub1.inUse _): () => Unit).verify().repeated(30 to 40)
        ((myResourceStub1.close _): () => Unit).verify().once()
      
        ((myResourceStub2.inUse _): () => Unit).verify().repeated(30 to 40)
        ((myResourceStub2.close _): () => Unit).verify().once()
      
        succeed
      }.toScalaFuture
  • ClosedPoolException

final class ClosedPoolException extends IllegalStateException

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ClosedPoolException
  2. IllegalStateException
  3. RuntimeException
  4. Exception
  5. Throwable
  6. Serializable
  7. AnyRef
  8. Any
Implicitly
  1. by RichException
  2. by any2stringadd
  3. by StringFormat
  4. by Ensuring
  5. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ClosedPoolException(message: String = "This pool has been closed.", cause: Throwable = null)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to any2stringadd[ClosedPoolException] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (ClosedPoolException, B)
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to ArrowAssoc[ClosedPoolException] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def addSuppressed(arg0: Throwable): Unit
    Definition Classes
    Throwable
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  9. def ensuring(cond: (ClosedPoolException) ⇒ Boolean, msg: ⇒ Any): ClosedPoolException
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to Ensuring[ClosedPoolException] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: (ClosedPoolException) ⇒ Boolean): ClosedPoolException
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to Ensuring[ClosedPoolException] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean, msg: ⇒ Any): ClosedPoolException
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to Ensuring[ClosedPoolException] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean): ClosedPoolException
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to Ensuring[ClosedPoolException] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  15. def fillInStackTrace(): Throwable
    Definition Classes
    Throwable
  16. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to StringFormat[ClosedPoolException] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  18. def getCause(): Throwable
    Definition Classes
    Throwable
  19. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  20. def getLocalizedMessage(): String
    Definition Classes
    Throwable
  21. def getMessage(): String
    Definition Classes
    Throwable
  22. def getStackTrace(): Array[StackTraceElement]
    Definition Classes
    Throwable
  23. final def getSuppressed(): Array[Throwable]
    Definition Classes
    Throwable
  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  25. def initCause(arg0: Throwable): Throwable
    Definition Classes
    Throwable
  26. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  27. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  29. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  30. def printStackTrace(arg0: PrintWriter): Unit
    Definition Classes
    Throwable
  31. def printStackTrace(arg0: PrintStream): Unit
    Definition Classes
    Throwable
  32. def printStackTrace(): Unit
    Definition Classes
    Throwable
  33. def setStackTrace(arg0: Array[StackTraceElement]): Unit
    Definition Classes
    Throwable
  34. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  35. def toString(): String
    Definition Classes
    Throwable → AnyRef → Any
  36. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  39. def [B](y: B): (ClosedPoolException, B)
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to ArrowAssoc[ClosedPoolException] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Deprecated Value Members

  1. def getStackTraceString: String
    Implicit
    This member is added by an implicit conversion from ClosedPoolException to RichException performed by method RichException in scala.Predef.
    Definition Classes
    RichException
    Annotations
    @deprecated
    Deprecated

    (Since version 2.11.0) use Throwable#getStackTrace

Inherited from IllegalStateException

Inherited from RuntimeException

Inherited from Exception

Inherited from Throwable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion RichException from ClosedPoolException to RichException

Inherited by implicit conversion any2stringadd from ClosedPoolException to any2stringadd[ClosedPoolException]

Inherited by implicit conversion StringFormat from ClosedPoolException to StringFormat[ClosedPoolException]

Inherited by implicit conversion Ensuring from ClosedPoolException to Ensuring[ClosedPoolException]

Inherited by implicit conversion ArrowAssoc from ClosedPoolException to ArrowAssoc[ClosedPoolException]

Ungrouped