Top Description Fields Constructors Methods
stormpot

pack-priv final Class BSlot<T extends Poolable>

Additional top-level classes in compilation unit: Padding1, PaddedAtomicInteger, Padding2, BSlotColdFields.

extends BSlotColdFields<T extends Poolable>
Class Inheritance
Imports
java.lang.invoke.MethodHandles, .VarHandle, java.util.concurrent.BlockingQueue, .TimeUnit, java.util.concurrent.atomic.AtomicInteger

This class is very sensitive to the memory layout, so be careful to measure the effect of even the tiniest changes! False-sharing can be quite sneaky.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
Inherited from stormpot.BSlotColdFields:
claimscreatedNanosliveobjpoisonpoisonedSlotsstamp

Constructor Summary

AccessConstructor and Description
pack-priv
BSlot(BlockingQueue<BSlot<T>> live, AtomicInteger poisonedSlots)

Method Summary

Modifier and TypeMethod and Description
private PoolException
pack-priv void
pack-priv void
pack-priv void
pack-priv void
public long
getAgeMillis()

Implements stormpot.SlotInfo.getAgeMillis.

Get the approximate number of milliseconds that have transpired since the object was allocated.
public long
getClaimCount()

Implements stormpot.SlotInfo.getClaimCount.

Get the number of times the object has been claimed since it was allocated.
private int
public T
getPoolable()

Implements stormpot.SlotInfo.getPoolable.

Get the Poolable object represented by this SlotInfo instance.
public long
getStamp()

Implements stormpot.SlotInfo.getStamp.

Get the stamp value that has been set on this SlotInfo, or 0 if none has been set since the Poolable was allocated.
pack-priv void
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
public void
release(Poolable
A reference to the Poolable object that is allocated for this slot, and is being released.
obj
)

Implements stormpot.Slot.release.

Signal to the pool that the currently claimed object in this slot has been released.
public void
setStamp(long
The new stamp value.
stamp
)

Implements stormpot.SlotInfo.setStamp.

Set the stamp value on this SlotInfo.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from stormpot.BSlotColdFields:
expire

Field Detail

CLAIMEDback to summary
private static final int CLAIMED
DEADback to summary
private static final int DEAD
LIVINGback to summary
private static final int LIVING
TLR_CLAIMEDback to summary
private static final int TLR_CLAIMED

Constructor Detail

BSlotback to summary
pack-priv BSlot(BlockingQueue<BSlot<T>> live, AtomicInteger poisonedSlots)

Method Detail

badStateOnTransitionToLiveback to summary
private PoolException badStateOnTransitionToLive(int slotState)
claim2deadback to summary
pack-priv void claim2dead()
claim2liveback to summary
pack-priv void claim2live()
claimTlr2liveback to summary
pack-priv void claimTlr2live()
dead2liveback to summary
pack-priv void dead2live()
getAgeMillisback to summary
public long getAgeMillis()

Implements stormpot.SlotInfo.getAgeMillis.

Doc from stormpot.SlotInfo.getAgeMillis.

Get the approximate number of milliseconds that have transpired since the object was allocated.

Returns:long

The age of the object in milliseconds.

Annotations
@Override
getClaimCountback to summary
public long getClaimCount()

Implements stormpot.SlotInfo.getClaimCount.

Doc from stormpot.SlotInfo.getClaimCount.

Get the number of times the object has been claimed since it was allocated.

Returns:long

The objects claim count.

Annotations
@Override
getClaimStateback to summary
private int getClaimState()
getPoolableback to summary
public T getPoolable()

Implements stormpot.SlotInfo.getPoolable.

Doc from stormpot.SlotInfo.getPoolable.

Get the Poolable object represented by this SlotInfo instance.

Warning

Do not release() Poolables from within an Expiration — doing so is a user error, and the behaviour of the pool in such a situation is unspecified and implementation specific. This means that dead-locks and infinite loops are possible outcomes as well.

Warning

Also note that accessing the Poolable through this method, from your Expiration implementation, is a potentially concurrent access. This means that you need to take thread-safety issues into consideration - especially if you intend on manipulating the Poolable. In particular, you might be racing with other threads that are checking if this Poolable is expired or not, and they might even have claimed the Poolable and put it to use, by the time it is returned from this method.

Returns:T

The Poolable being examined for validity. Never `null`.

Annotations
@Override
getStampback to summary
public long getStamp()

Implements stormpot.SlotInfo.getStamp.

Doc from stormpot.SlotInfo.getStamp.

Get the stamp value that has been set on this SlotInfo, or 0 if none has been set since the Poolable was allocated. Apart from the zero-value, the actual meaning of this value is completely up to the Expiration that sets it.

Returns:long

The current stamp value.

Annotations
@Override
incrementClaimsback to summary
pack-priv void incrementClaims()
isClaimedback to summary
pack-priv boolean isClaimed()
isDeadback to summary
pack-priv boolean isDead()
isLiveback to summary
pack-priv boolean isLive()
live2claimback to summary
pack-priv boolean live2claim()
live2claimTlrback to summary
pack-priv boolean live2claimTlr()
live2deadback to summary
pack-priv boolean live2dead()
releaseback to summary
public void release(Poolable obj)

Implements stormpot.Slot.release.

Doc from stormpot.Slot.release.

Signal to the pool that the currently claimed object in this slot has been released. It is a user error to release a slot that is not currently claimed. It is likewise a user error to release a Slot while inside the Allocators allocate method, or the Expirations hasExpired method. On the other hand, it is _not_ an error to release a Poolable from a thread other than the one that claimed it. Pools are free to throw a PoolException if they detect any of these wrong uses, but it is not guaranteed and the exact behaviour is not specified. "Unspecified behaviour" means that dead-locks and infinite loops are fair responses as well. Therefore, heed the advice and don't misuse release! Pools must, however, guarantee that an object is never deallocated more than once. This guarantee must hold even if release is misused.

Parameters
obj:Poolable

A reference to the Poolable object that is allocated for this slot, and is being released.

setStampback to summary
public void setStamp(long stamp)

Implements stormpot.SlotInfo.setStamp.

Doc from stormpot.SlotInfo.setStamp.

Set the stamp value on this SlotInfo. This method is only thread-safe to call from within the scope of the Expiration#hasExpired(SlotInfo) method. The stamp value is 0 by default, if it has not been set after the Poolable has been allocated. Its meaning is otherwise up to the particular Expiration that might use it.

Parameters
stamp:long

The new stamp value.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override