Top Description Inners Fields Constructors Methods
io.undertow.util

public Class SimpleObjectPool<T>

extends Object
implements ObjectPool
Class Inheritance
All Implemented Interfaces
io.undertow.util.ObjectPool
Imports
java.util.concurrent.LinkedBlockingDeque, java.util.concurrent.atomic.AtomicIntegerFieldUpdater, java.util.function.Consumer, .Supplier, io.undertow.UndertowMessages

Simple pool that attempts to maintain a specified number of objects in the pool. If more objects are created new ones are created on the fly, and then destroyed once the pool is full.
Authors
ckozak, Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Consumer<T>
private final LinkedBlockingDeque<T>
private final Consumer<T>
private final Supplier<T>

Constructor Summary

AccessConstructor and Description
public
SimpleObjectPool(int poolSize, Supplier<T> supplier, Consumer<T> recycler, Consumer<T> consumer)

public
SimpleObjectPool(int poolSize, Supplier<T> supplier, Consumer<T> consumer)

Method Summary

Modifier and TypeMethod and Description
public PooledObject<T>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

consumerback to summary
private final Consumer<T> consumer
poolback to summary
private final LinkedBlockingDeque<T> pool
recyclerback to summary
private final Consumer<T> recycler
supplierback to summary
private final Supplier<T> supplier

Constructor Detail

SimpleObjectPoolback to summary
public SimpleObjectPool(int poolSize, Supplier<T> supplier, Consumer<T> recycler, Consumer<T> consumer)
SimpleObjectPoolback to summary
public SimpleObjectPool(int poolSize, Supplier<T> supplier, Consumer<T> consumer)

Method Detail

allocateback to summary
public PooledObject<T> allocate()

Implements io.undertow.util.ObjectPool.allocate.

Annotations
@Override
io.undertow.util back to summary

private final Class SimpleObjectPool.SimplePooledObject<T>

extends Object
implements PooledObject<T>
Class Inheritance
All Implemented Interfaces
io.undertow.util.PooledObject, java.lang.AutoCloseable, java.io.Closeable

Field Summary

Modifier and TypeField and Description
private volatile int
private static final AtomicIntegerFieldUpdater<SimpleObjectPool.SimplePooledObject<T>>
private final T
private final SimpleObjectPool<T>

Constructor Summary

AccessConstructor and Description
pack-priv
SimplePooledObject(T object, SimpleObjectPool<T> objectPool)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.undertow.util.PooledObject.close.

Closes this stream and releases any system resources associated with it.

public T
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closedback to summary
private volatile int closed
closedUpdaterback to summary
private static final AtomicIntegerFieldUpdater<SimpleObjectPool.SimplePooledObject<T>> closedUpdater
objectback to summary
private final T object
objectPoolback to summary
private final SimpleObjectPool<T> objectPool

Constructor Detail

SimplePooledObjectback to summary
pack-priv SimplePooledObject(T object, SimpleObjectPool<T> objectPool)

Method Detail

closeback to summary
public void close()

Implements io.undertow.util.PooledObject.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
getObjectback to summary
public T getObject()

Implements io.undertow.util.PooledObject.getObject.

Annotations
@Override