- Type Parameters:
T- The concretePoolableobject type.
- All Implemented Interfaces:
Serializable
A
RefillPile can collect objects, in a concurrent and wait-free manner,
before releasing them all to a queue.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRefillPile(BlockingQueue<BSlot<T>> refillQueue) Create a refill pile that will refill into the given queue. -
Method Summary
Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
Constructor Details
-
RefillPile
Create a refill pile that will refill into the given queue.- Parameters:
refillQueue- The queue to refill into.
-
-
Method Details
-
push
Push the given slot onto the stack. This method is wait-free.- Parameters:
slot- The slot instance to be pushed onto the stack.
-
pop
Remove a slot from the pile, if there is any.- Returns:
- A slot that was removed from the pile, or
nullif there were no slots to remove.
-
refill
public boolean refill()Refill the target queue with all the slots that have been pushed onto this stack. This method atomically pops all elements from the stack at once, and then pushed onto the queue one by one.- Returns:
trueif any slots has been offered to the queue, orfalseif there were no slots in the pile.
-
toString
- Overrides:
toStringin classAtomicReference<RefillSlot<T extends Poolable>>
-