1 | package net.spy.memcached.ops; |
2 | |
3 | import java.util.concurrent.ArrayBlockingQueue; |
4 | import java.util.concurrent.BlockingQueue; |
5 | |
6 | /** |
7 | * OperationQueueFactory that uses an ArrayBlockingQueue. |
8 | */ |
9 | public class ArrayOperationQueueFactory implements OperationQueueFactory { |
10 | |
11 | private final int capacity; |
12 | |
13 | /** |
14 | * Create an ArrayOperationQueueFactory that creates blocking queues with |
15 | * the given capacity. |
16 | * |
17 | * @param cap maximum size of a queue produced by this factory |
18 | */ |
19 | public ArrayOperationQueueFactory(int cap) { |
20 | super(); |
21 | capacity = cap; |
22 | } |
23 | |
24 | /* (non-Javadoc) |
25 | * @see net.spy.memcached.ops.OperationQueueFactory#create() |
26 | */ |
27 | public BlockingQueue<Operation> create() { |
28 | return new ArrayBlockingQueue<Operation>(capacity); |
29 | } |
30 | |
31 | } |