io.github.andrebeat.pool

Lease

trait Lease[A <: AnyRef] extends AnyRef

A lease on an object requested from a io.github.andrebeat.pool.Pool allowing the object to be accessed and then released back to the pool when no longer needed.

A

the type of object stored in this lease

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Lease
  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 a: A

    Attributes
    protected[this]
  2. abstract def handleInvalidate(): Unit

    Attributes
    protected[this]
  3. abstract def handleRelease(): Unit

    Attributes
    protected[this]

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 apply[B](f: (A) ⇒ B): B

    Gets the value from the lease, passing it onto the provided function and releasing it back to the pool after the function is run.

    Gets the value from the lease, passing it onto the provided function and releasing it back to the pool after the function is run.

    If needed, it is possible to invalidate the lease from inside the provided function, for example:

    val lease = pool.acquire()
    val x = lease { v =>
      if (/* invalid condition */ { lease.invalidate(); None }
      else Some(/* result */
    }

    It is important that no references are kept to the leased object after this method finishes. For example, the following code is invalid since the variable x holds a reference to an object that was returned to the pool.

    val lease = pool.acquire()
    val x = lease(identity)
    B

    the type of object returned by the function f

    f

    a function that uses the value stored in the lease to produce a new value

    returns

    the value produced by the function f.

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def get(): A

    Returns the object being leased by the pool.

    Returns the object being leased by the pool. Throws an java.lang.IllegalStateException if the lease has already been released or invalidated.

    returns

    the object being leased by the pool.

  13. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  15. def invalidate(): Unit

    Invalidates the current lease.

    Invalidates the current lease. The object is "destroyed" and is no longer eligible to be returned to the pool. Additionally, the number of live objects in the pool is decremented.

    If the lease has already been released or invalidated this method does nothing.

  16. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  20. def release(): Unit

    Releases the object back to the pool for reuse.

    Releases the object back to the pool for reuse. When releasing an object it is mandatory that there are no references to the returned object.

    When an object is released to a pool that has already been closed it is "destroyed".

    If the lease has already been released or invalidated this method does nothing.

  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  22. def toString(): String

    Definition Classes
    AnyRef → Any
  23. def use[B](f: (A) ⇒ B): B

    Gets the value from the lease, passing it onto the provided function and releasing it back to the pool after the function is run.

    Gets the value from the lease, passing it onto the provided function and releasing it back to the pool after the function is run.

    Alias method for apply.

    See also

    io.github.andrebeat.pool.Lease.apply

  24. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped