public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * Appends bytes to the end of the stream * @param buf * @throws IOException * @see #write(byte[],int,int) */ public void write(byte[] buf) throws IOException { if(buf != null) write(buf, 0, buf.length); }
sanityCheck(buf, offset, length); while(bytes_written < length && !closed) { if(read_pos > 0 && length - bytes_written > remaining()) compact(); if(remaining() > 0) { int bytes_to_write=Math.min(length-bytes_written, remaining()); System.arraycopy(buf, offset+bytes_written, this.buf, write_pos, bytes_to_write); write_pos+=bytes_to_write;
public int read(byte[] b, int off, int len) throws IOException { sanityCheck(b, off, len); int bytes_read=0; int bytes_to_be_read=Math.min(b.length, len); lock.lock(); try { while(bytes_read < bytes_to_be_read) { if(read_pos < write_pos) { int bytes_to_read=Math.min(len-bytes_read, size()); System.arraycopy(buf, read_pos, b, bytes_read + off, bytes_to_read); read_pos+=bytes_to_read; bytes_read+=bytes_to_read; not_full.signalAll(); continue; } if(closed) return bytes_read > 0? bytes_read : -1; try { not_empty.await(); } catch(InterruptedException e) { } } return bytes_read > 0? bytes_read : -1; } finally { lock.unlock(); } }
public int available() throws IOException { lock.lock(); try { return size(); } finally { lock.unlock(); } }
protected Tuple<InputStream,Object> createStreamToProvider(final Address provider, final StateHeader hdr) { Util.close(input_stream); input_stream=new BlockingInputStream(buffer_size); return new Tuple<InputStream,Object>(input_stream, null); }
sanityCheck(buf, offset, length); while(bytes_written < length && !closed) { if(read_pos > 0 && length - bytes_written > remaining()) compact(); if(remaining() > 0) { int bytes_to_write=Math.min(length-bytes_written, remaining()); System.arraycopy(buf, offset+bytes_written, this.buf, write_pos, bytes_to_write); write_pos+=bytes_to_write;
public int read(byte[] b, int off, int len) throws IOException { sanityCheck(b, off, len); int bytes_read=0; int bytes_to_be_read=Math.min(b.length, len); lock.lock(); try { while(bytes_read < bytes_to_be_read) { if(read_pos < write_pos) { int bytes_to_read=Math.min(len-bytes_read, size()); System.arraycopy(buf, read_pos, b, bytes_read + off, bytes_to_read); read_pos+=bytes_to_read; bytes_read+=bytes_to_read; not_full.signalAll(); continue; } if(closed) return bytes_read > 0? bytes_read : -1; try { not_empty.await(); } catch(InterruptedException e) { } } return bytes_read > 0? bytes_read : -1; } finally { lock.unlock(); } }
public int available() throws IOException { lock.lock(); try { return size(); } finally { lock.unlock(); } }
protected Tuple<InputStream,Object> createStreamToProvider(final Address provider, final StateHeader hdr) { Util.close(input_stream); input_stream=new BlockingInputStream(buffer_size); return new Tuple<InputStream,Object>(input_stream, null); }
sanityCheck(buf, offset, length); while(bytes_written < length && !closed) { if(read_pos > 0 && length - bytes_written > remaining()) compact(); if(remaining() > 0) { int bytes_to_write=Math.min(length-bytes_written, remaining()); System.arraycopy(buf, offset+bytes_written, this.buf, write_pos, bytes_to_write); write_pos+=bytes_to_write;
public int read(byte[] b, int off, int len) throws IOException { sanityCheck(b, off, len); int bytes_read=0; int bytes_to_be_read=Math.min(b.length, len); lock.lock(); try { while(bytes_read < bytes_to_be_read) { if(read_pos < write_pos) { int bytes_to_read=Math.min(len-bytes_read, size()); System.arraycopy(buf, read_pos, b, bytes_read + off, bytes_to_read); read_pos+=bytes_to_read; bytes_read+=bytes_to_read; not_full.signalAll(); continue; } if(closed) return bytes_read > 0? bytes_read : -1; try { not_empty.await(); } catch(InterruptedException e) { } } return bytes_read > 0? bytes_read : -1; } finally { lock.unlock(); } }
/** * Appends bytes to the end of the stream * @param buf * @throws IOException * @see #write(byte[],int,int) */ public void write(byte[] buf) throws IOException { if(buf != null) write(buf, 0, buf.length); }
public int available() throws IOException { lock.lock(); try { return size(); } finally { lock.unlock(); } }
protected Tuple<InputStream,Object> createStreamToProvider(final Address provider, final StateHeader hdr) { Util.close(input_stream); input_stream=new BlockingInputStream(buffer_size); return new Tuple<InputStream,Object>(input_stream, null); }
public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * Appends bytes to the end of the stream * @param buf * @throws IOException * @see #write(byte[],int,int) */ public void write(byte[] buf) throws IOException { if(buf != null) write(buf, 0, buf.length); }