Fixed size issues (now explicit) for blocking queues
This commit is contained in:
parent
9e4243c7d4
commit
db545c274b
|
@ -26,14 +26,14 @@ class BlockingPool<T> extends ObjectPool<T> {
|
|||
private final PoolableObject<T> poolableObject;
|
||||
|
||||
BlockingPool(PoolableObject<T> poolableObject, int size) {
|
||||
this(poolableObject, new ArrayBlockingQueue<T>(size));
|
||||
this(poolableObject, new ArrayBlockingQueue<T>(size), size);
|
||||
}
|
||||
|
||||
BlockingPool(final PoolableObject<T> poolableObject, final BlockingQueue<T> queue) {
|
||||
BlockingPool(final PoolableObject<T> poolableObject, final BlockingQueue<T> queue, final int size) {
|
||||
this.poolableObject = poolableObject;
|
||||
this.queue = queue;
|
||||
|
||||
for (int x = 0; x < queue.size(); x++) {
|
||||
for (int x = 0; x < size; x++) {
|
||||
T e = poolableObject.create();
|
||||
poolableObject.onReturn(e);
|
||||
this.queue.add(e);
|
||||
|
|
|
@ -43,7 +43,7 @@ class ObjectPool<T> implements Pool<T> {
|
|||
*
|
||||
* @return a blocking pool using the default ArrayBlockingQueue implementation of a specific size
|
||||
*/
|
||||
public static <T> ObjectPool<T> Blocking(PoolableObject<T> poolableObject, int size) {
|
||||
public static <T> ObjectPool<T> Blocking(final PoolableObject<T> poolableObject, final int size) {
|
||||
return new BlockingPool<T>(poolableObject, size);
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,8 @@ class ObjectPool<T> implements Pool<T> {
|
|||
*
|
||||
* @return a blocking pool using the default ArrayBlockingQueue implementation of a specific size
|
||||
*/
|
||||
public static <T> ObjectPool<T> Blocking(PoolableObject<T> poolableObject, BlockingQueue<T> queue) {
|
||||
return new BlockingPool<T>(poolableObject, queue);
|
||||
public static <T> ObjectPool<T> Blocking(final PoolableObject<T> poolableObject, final BlockingQueue<T> queue, final int size) {
|
||||
return new BlockingPool<T>(poolableObject, queue, size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ class ObjectPool<T> implements Pool<T> {
|
|||
*
|
||||
* @return a blocking pool using the default ConcurrentLinkedQueue implementation
|
||||
*/
|
||||
public static <T> ObjectPool<T> NonBlocking(PoolableObject<T> poolableObject) {
|
||||
public static <T> ObjectPool<T> NonBlocking(final PoolableObject<T> poolableObject) {
|
||||
return new NonBlockingPool<T>(poolableObject);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class ObjectPool<T> implements Pool<T> {
|
|||
*
|
||||
* @return a blocking pool using the default ConcurrentLinkedQueue implementation
|
||||
*/
|
||||
public static <T> ObjectPool<T> NonBlocking(PoolableObject<T> poolableObject, Queue<T> queue) {
|
||||
public static <T> ObjectPool<T> NonBlocking(final PoolableObject<T> poolableObject, final Queue<T> queue) {
|
||||
return new NonBlockingPool<T>(poolableObject, queue);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class ObjectPool<T> implements Pool<T> {
|
|||
*
|
||||
* @return a blocking pool using the default ConcurrentLinkedQueue implementation
|
||||
*/
|
||||
public static <T> ObjectPool<T> NonBlockingSoftReference(PoolableObject<T> poolableObject) {
|
||||
public static <T> ObjectPool<T> NonBlockingSoftReference(final PoolableObject<T> poolableObject) {
|
||||
return new NonBlockingSoftPool<T>(poolableObject);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class ObjectPool<T> implements Pool<T> {
|
|||
*
|
||||
* @return a blocking pool using the default ConcurrentLinkedQueue implementation
|
||||
*/
|
||||
public static <T> ObjectPool<T> NonBlockingSoftReference(PoolableObject<T> poolableObject, Queue<SoftReference<T>> queue) {
|
||||
public static <T> ObjectPool<T> NonBlockingSoftReference(final PoolableObject<T> poolableObject, final Queue<SoftReference<T>> queue) {
|
||||
return new NonBlockingSoftPool<T>(poolableObject, queue);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue