Top Inners Fields Constructors Methods
com.amazon.ion.impl.bin.utf8

pack-priv abstract Class Pool<T extends Poolable<?>>

extends Object
Class Inheritance
Known Direct Subclasses
com.amazon.ion.impl.bin.utf8.Utf8StringDecoderPool, com.amazon.ion.impl.bin.utf8.Utf8StringEncoderPool, com.amazon.ion.impl.bin.utf8.ByteBufferPool
Imports
java.util.Queue, java.util.concurrent.ConcurrentLinkedQueue, java.util.concurrent.atomic.AtomicInteger

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
Pool.Allocator<
the type of object.
T extends Poolable<?>
>

Allocates objects to be pooled.

Field Summary

Modifier and TypeField and Description
private final Pool.Allocator<T>
private static final int
private final Queue<T>
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
pack-priv
Pool(Pool.Allocator<T> allocator)

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

An object.
getOrCreate
()

If the pool is not empty, removes an object from the pool and returns it; otherwise, constructs a new object.

public void
returnToPool(T
An object to add to the pool.
object
)

Adds the provided instance to the pool.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allocatorback to summary
private final Pool.Allocator<T> allocator
MAX_QUEUE_SIZEback to summary
private static final int MAX_QUEUE_SIZE
objectQueueback to summary
private final Queue<T> objectQueue
sizeback to summary
private final AtomicInteger size

Constructor Detail

Poolback to summary
pack-priv Pool(Pool.Allocator<T> allocator)

Method Detail

getOrCreateback to summary
public T getOrCreate()

If the pool is not empty, removes an object from the pool and returns it; otherwise, constructs a new object.

Returns:T

An object.

returnToPoolback to summary
public void returnToPool(T object)

Adds the provided instance to the pool. If the pool is full, the instance will be discarded. Callers MUST NOT use an object after returning it to the pool.

Parameters
object:T

An object to add to the pool.

com.amazon.ion.impl.bin.utf8 back to summary

pack-priv Interface Pool.Allocator<T extends Poolable<?>>

Type Parameters
<T>
the type of object.

Allocates objects to be pooled.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

a new instance.
newInstance
(Pool<T>
the pool to which the new object will be linked.
pool
)

Allocate a new object and link it to the given pool.

Method Detail

newInstanceback to summary
public T newInstance(Pool<T> pool)

Allocate a new object and link it to the given pool.

Parameters
pool:Pool<T>

the pool to which the new object will be linked.

Returns:T

a new instance.