io.github.andrebeat.pool

Pool

trait Pool[A <: AnyRef] extends AnyRef

A pool of objects that may be leased. It is expected that all implementations of this trait are thread-safe.

A

the type of object to pool

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Pool
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def capacity(): Int

    Returns the capacity of the pool, i.

    Returns the capacity of the pool, i.e. the maximum number of objects the pool can hold.

    returns

    the capacity of the pool.

  2. abstract def dispose(a: A): Unit

    Object "destructor".

    Object "destructor". This method is called whenever the object is evicted from the pool. For example, when doing connection pooling it is necessary to close the connection whenever it is evicted (i.e. permanently removed) from the pool.

    Attributes
    protected
  3. abstract def factory(): A

    Factory method for creating new objects.

    Factory method for creating new objects.

    returns

    a new object.

    Attributes
    protected
  4. abstract def handleAcquire(): Lease[A]

    Attributes
    protected
  5. abstract def handleClose(): Unit

    Attributes
    protected
  6. abstract def handleDrain(): Unit

    Attributes
    protected
  7. abstract def handleFill(): Unit

    Attributes
    protected
  8. abstract def handleTryAcquire(atMost: Duration): Option[Lease[A]]

    Attributes
    protected
  9. abstract def handleTryAcquire(): Option[Lease[A]]

    Attributes
    protected
  10. abstract def healthCheck(a: A): Boolean

    An health check that is performed on an object before its leased from the pool.

    An health check that is performed on an object before its leased from the pool. If the health check passes the object is successfully leased. Otherwise, the object is destroyed (and a new one is fetched or created)

    Attributes
    protected
  11. abstract def live(): Int

    Returns the number of live objects, i.

    Returns the number of live objects, i.e. the number of currently pooled objects plus leased objects.

    The value returned by this method is only accurate when the referenceType is io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only when trying to acquire an object.

    returns

    the number of live objects.

  12. abstract def referenceType: ReferenceType

    Returns the io.github.andrebeat.pool.ReferenceType of the objects stored in the pool.

  13. abstract def reset(a: A): Unit

    Resets the internal state of object.

    Resets the internal state of object. This method is called on an object whenever it is added/released back to the pool. For example, if pooling an object like a java.nio.ByteBuffer it might make sense to call its reset() method whenever the object is released to the pool, so that its future users do not observe the internal state introduced by previous ones.

    Attributes
    protected
  14. abstract def size(): Int

    Returns the number of objects in the pool.

    Returns the number of objects in the pool.

    The value returned by this method is only accurate when the referenceType is io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only when trying to acquire an object.

    returns

    the number of objects in the pool.

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def acquire(): Lease[A]

    Acquire a lease for an object blocking if none is available.

    Acquire a lease for an object blocking if none is available.

    returns

    a lease for an object from this pool.

    Exceptions thrown
    ClosedPoolException

    If this pool is closed.

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def close(): Unit

    Closes this pool, and properly disposes of each pooled object, releasing any resources associated with the pool (e.

    Closes this pool, and properly disposes of each pooled object, releasing any resources associated with the pool (e.g. background timer threads).

    If the pool has already been closed this method does nothing.

  10. val closed: AtomicBoolean

    Attributes
    protected[this]
  11. def drain(): Unit

    Drains the object pool, i.

    Drains the object pool, i.e. evicts every object currently pooled.

    Exceptions thrown
    ClosedPoolException

    If this pool is closed.

  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def fill(): Unit

    Fills the object pool by creating (and pooling) new objects until the number of live objects reaches the pool capacity.

    Fills the object pool by creating (and pooling) new objects until the number of live objects reaches the pool capacity.

    Exceptions thrown
    ClosedPoolException

    If this pool is closed.

  15. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  19. def leased(): Int

    Returns the number of leased objects.

    Returns the number of leased objects.

    The value returned by this method is only accurate when the referenceType is io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only when trying to acquire an object.

    returns

    the number of leased objects.

  20. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  21. final def notify(): Unit

    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  24. def toString(): String

    Definition Classes
    AnyRef → Any
  25. def tryAcquire(atMost: Duration): Option[Lease[A]]

    Try to acquire a lease for an object blocking at most until the given duration.

    Try to acquire a lease for an object blocking at most until the given duration.

    atMost

    maximum wait time for the lease to be available.

    returns

    a lease for an object from this pool if available until the given duration, None otherwise.

    Exceptions thrown
    ClosedPoolException

    If this pool is closed.

  26. def tryAcquire(): Option[Lease[A]]

    Try to acquire a lease for an object without blocking.

    Try to acquire a lease for an object without blocking.

    returns

    a lease for an object from this pool if available, None otherwise.

    Exceptions thrown
    ClosedPoolException

    If this pool is closed.

  27. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped