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
- Alphabetic
- By Inheritance
- Lease
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
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.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
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.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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
. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )