| 1 | package stream; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.concurrent.ArrayBlockingQueue; |
| 5 | |
| 6 | public class ConcurrentReadListDepot<K> { |
| 7 | |
| 8 | |
| 9 | |
| 10 | public ConcurrentReadListDepot(int bufSize, int numBufs){ |
| 11 | bufferSize=bufSize; |
| 12 | bufferCount=numBufs; |
| 13 | |
| 14 | lists=new ArrayList[numBufs]; |
| 15 | empty=new ArrayBlockingQueue<ArrayList<K>>(numBufs+1); |
| 16 | full=new ArrayBlockingQueue<ArrayList<K>>(numBufs+1); |
| 17 | |
| 18 | for(int i=0; i<lists.length; i++){ |
| 19 | lists[i]=new ArrayList<K>(bufSize); |
| 20 | empty.add(lists[i]); |
| 21 | } |
| 22 | |
| 23 | } |
| 24 | |
| 25 | |
| 26 | public final ArrayBlockingQueue<ArrayList<K>> empty; |
| 27 | public final ArrayBlockingQueue<ArrayList<K>> full; |
| 28 | |
| 29 | public final int bufferSize; |
| 30 | public final int bufferCount; |
| 31 | |
| 32 | |
| 33 | private final ArrayList<K>[] lists; |
| 34 | |
| 35 | } |