Ejemplo n.º 1
0
 public PipedOutputStream(
     final int bufferSize,
     final SizedRecyclingSupplier<byte[]> bufferProvider,
     final Long globalDeadline) {
   this.bufferProvider = bufferProvider;
   buffer = bufferProvider.get(bufferSize);
   startIdx = 0;
   endIdx = 0;
   readerPerceivedEndIdx = 0;
   writerClosed = false;
   nrReadStreams = 0;
   this.globalDeadline = globalDeadline;
 }
Ejemplo n.º 2
0
 @Override
 @WillClose
 public void close() {
   synchronized (sync) {
     if (!writerClosed) {
       try {
         writerClosed = true;
         flush();
       } finally {
         if (nrReadStreams == 0 && availableToRead() == 0) {
           bufferProvider.recycle(buffer);
           buffer = null;
         }
         sync.notifyAll();
       }
     }
   }
 }