Class Pool.Entry
- Direct Known Subclasses:
Pool.MonoEntry
,Pool.MultiEntry
A Pool entry that holds metadata and a pooled object.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Enables this, previouslyreserved
, Entry.(package private) int
abstract boolean
isClosed()
abstract boolean
isIdle()
(package private) boolean
abstract boolean
isInUse()
boolean
Deprecated.MaxUsage functionalities will be removedabstract boolean
boolean
release()
Releases this Entry.boolean
remove()
Removes this Entry from the Pool.(package private) void
setUsageCount
(int usageCount) (package private) abstract boolean
Tries to acquire this Entry.(package private) abstract boolean
tryEnable
(boolean acquire) Tries to enable, and possible also acquire, this Entry.(package private) abstract boolean
Tries to release this Entry.(package private) abstract boolean
Tries to remove the entry by marking it as closed.
-
Field Details
-
pooled
-
-
Constructor Details
-
Entry
public Entry()
-
-
Method Details
-
enable
Enables this, previously
reserved
, Entry.An entry returned from the
Pool.reserve()
method must be enabled with this method, once and only once, before it is usable by the pool.The entry may be enabled and not acquired, in which case it is immediately available to be acquired, potentially by another thread; or it can be enabled and acquired atomically so that no other thread can acquire it, although the acquire may still fail if the pool has been closed.
- Parameters:
pooled
- the pooled object for this Entryacquire
- whether this Entry should be atomically enabled and acquired- Returns:
- whether this Entry was enabled
- Throws:
IllegalStateException
- if this Entry was already enabled
-
getPooled
- Returns:
- the pooled object
-
release
public boolean release()Releases this Entry.
This is equivalent to calling
Pool.release(Pool.Entry)
passing this entry.- Returns:
- whether this Entry was released
-
remove
public boolean remove()Removes this Entry from the Pool.
This is equivalent to calling
Pool.remove(Pool.Entry)
passing this entry.- Returns:
- whether this Entry was removed
-
tryEnable
abstract boolean tryEnable(boolean acquire) Tries to enable, and possible also acquire, this Entry.
- Parameters:
acquire
- whether to also acquire this Entry- Returns:
- whether this Entry was enabled
-
tryAcquire
abstract boolean tryAcquire()Tries to acquire this Entry.
- Returns:
- whether this Entry was acquired
-
tryRelease
abstract boolean tryRelease()Tries to release this Entry.
- Returns:
- true if this Entry was released,
false if
tryRemove()
should be called.
-
tryRemove
abstract boolean tryRemove()Tries to remove the entry by marking it as closed.
- Returns:
- whether the entry can be removed from the containing pool
-
isClosed
public abstract boolean isClosed()- Returns:
- whether this Entry is closed
-
isReserved
public abstract boolean isReserved()- Returns:
- whether this Entry is reserved
-
isIdle
public abstract boolean isIdle()- Returns:
- whether this Entry is idle
-
isInUse
public abstract boolean isInUse()- Returns:
- whether this entry is in use.
-
isOverUsed
Deprecated.MaxUsage functionalities will be removed- Returns:
- whether this entry has been used beyond
Pool.getMaxUsageCount()
-
isIdleAndOverUsed
boolean isIdleAndOverUsed() -
getUsageCount
int getUsageCount() -
setUsageCount
void setUsageCount(int usageCount)
-