Trait

io.github.andrebeat.pool

Lease

Related Doc: package pool

Permalink

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
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def a: A

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

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

    Permalink
    Attributes
    protected[this]

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply[B](f: (A) ⇒ B): B

    Permalink

    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.

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

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

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

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

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

    Permalink

    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.

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

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

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

    Permalink

    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.

  14. final def isInstanceOf[T0]: Boolean

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

    Permalink
    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. def release(): Unit

    Permalink

    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.

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

    Permalink
    Definition Classes
    AnyRef
  20. def toString(): String

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

    Permalink

    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

  22. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped