From 0cebcc56a4fb41b27b52f54cccdeefe33fcddf3d Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Thu, 12 Jul 2012 11:28:55 +0200 Subject: [PATCH] move to use linked blocking queue --- .../store/bytebuffer/CachingByteBufferAllocator.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/lucene/store/bytebuffer/CachingByteBufferAllocator.java b/src/main/java/org/apache/lucene/store/bytebuffer/CachingByteBufferAllocator.java index 574ef20c576..925a76cbd08 100644 --- a/src/main/java/org/apache/lucene/store/bytebuffer/CachingByteBufferAllocator.java +++ b/src/main/java/org/apache/lucene/store/bytebuffer/CachingByteBufferAllocator.java @@ -19,7 +19,8 @@ package org.apache.lucene.store.bytebuffer; import java.io.IOException; import java.nio.ByteBuffer; -import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; /** * The caching byte buffer allocator allows to define a global size for both the small and large buffers @@ -27,8 +28,8 @@ import java.util.concurrent.ArrayBlockingQueue; */ public class CachingByteBufferAllocator extends PlainByteBufferAllocator { - private final ArrayBlockingQueue smallCache; - private final ArrayBlockingQueue largeCache; + private final BlockingQueue smallCache; + private final BlockingQueue largeCache; /** * @param direct If set to true, will allocate direct buffers (off heap). @@ -40,8 +41,8 @@ public class CachingByteBufferAllocator extends PlainByteBufferAllocator { public CachingByteBufferAllocator(boolean direct, int smallBufferSizeInBytes, int largeBufferSizeInBytes, int smallCacheSizeInBytes, int largeCacheSizeInBytes) { super(direct, smallBufferSizeInBytes, largeBufferSizeInBytes); - this.smallCache = new ArrayBlockingQueue(smallCacheSizeInBytes / smallBufferSizeInBytes); - this.largeCache = new ArrayBlockingQueue(largeCacheSizeInBytes / largeBufferSizeInBytes); + this.smallCache = new LinkedBlockingQueue(smallCacheSizeInBytes / smallBufferSizeInBytes); + this.largeCache = new LinkedBlockingQueue(largeCacheSizeInBytes / largeBufferSizeInBytes); }