@Override public final E next() { try { return buff.get(i ++); } catch(final IndexOutOfBoundsException e) { throw new NoSuchElementException(); } }
protected ListIteratorImpl(final CircularBuffer<E> buff, final int startIndex) { this.buff = buff; this.size = buff.size(); this.startIndex = startIndex; this.i = startIndex; }
@Override protected void doClose() throws IOException { itemsBuff.clear(); } }
int n = srcBuff.size(); if(n > 0) { if(n == 1) { if(output.put(srcBuff.get(0))) { srcBuff.clear(); srcBuff.removeFirst(n);
public TransferFiber( final FibersExecutor executor, final CircularBuffer<T> itemsBuff, final Input<T> input, final Output<T> output ) { super(executor); this.input = input; this.output = output; this.itemsBuff = itemsBuff; this.capacity = itemsBuff.capacity(); }
@Override public boolean await(final long timeout, final TimeUnit timeUnit) throws IllegalStateException, InterruptedException { if(isShutdown()) { final long invokeTimeMillis = System.currentTimeMillis(); final long timeOutMillis = timeUnit.toMillis(timeout); while(timeOutMillis > System.currentTimeMillis() - invokeTimeMillis) { if(itemsBuff.isEmpty()) { return true; } LockSupport.parkNanos(1); } return false; } else { return super.await(timeout, timeUnit); } }
@Override public final boolean put(final T ioTask) throws IOException { if(isStopped()) { throw new EOFException(); } final O output = selectOutput(); final CircularBuffer<T> dstBuff = buffs.get(output); final Lock dstBuffLock = buffLocks.get(output); if(dstBuff != null && dstBuffLock != null && dstBuffLock.tryLock()) { try { return dstBuff.add(ioTask); } finally { dstBuffLock.unlock(); } } else { return false; } }
input.get(itemsBuff, capacity - itemsBuff.size()); n = itemsBuff.size(); final T item = itemsBuff.get(0); if(output.put(item)) { itemsBuff.clear(); itemsBuff.removeFirst(n);
int pendingOpCount = opBuff.size(); int n = batchSize - pendingOpCount; if (n == 1) { // single mode branch try { final O op = opBuff.get(0); if (opOutput.put(op)) { outputOpCounter.increment(); if (pendingOpCount == 1) { opBuff.clear(); } else { opBuff.remove(0); outputOpCounter.add(n); if (n < pendingOpCount) { opBuff.removeFirst(n); } else { opBuff.clear();
@Override public final E previous() { if(hasPrevious()) { return buff.get(-- i); } else { throw new NoSuchElementException(); } }