private void waitUntilEmpty() throws IOException { try { while (this.state != State.EMPTY) this.notFull.await(); } catch (InterruptedException ie) { throw new InterruptedIOException(); // SUPPRESS CHECKSTYLE AvoidHidingCause } this.checkException(); }
@Override public void close() throws IOException { this.lock.lock(); try { this.flush(); this.state = State.CLOSED; this.buffer = null; this.out.close(); this.notEmpty.signal(); } finally { this.lock.unlock(); } }
@Override public void flush() throws IOException { this.lock.lock(); try { if (this.state == State.CLOSED) throw new IOException("Stream is closed"); this.waitUntilEmpty(); this.out.flush(); } finally { this.lock.unlock(); } }
/** * @throws IOException The background thread got this exception */ @Override public void write(int b) throws IOException { this.lock.lock(); try { if (this.state == State.CLOSED) throw new IOException("Stream is closed"); this.waitUntilNotFull(); // Put the byte. this.buffer.put(this.tail, (byte) b); this.tail = (this.tail + 1) % this.capacity; this.state = this.tail == this.head ? State.FULL : State.PART; // Wake up the background thread. this.notEmpty.signal(); } finally { this.lock.unlock(); } }
try { while (this.state != State.CLOSED) { this.waitUntilNotEmpty();
/** * @throws IOException The background thread got this exception */ @Override public void write(int b) throws IOException { this.lock.lock(); try { if (this.state == State.CLOSED) throw new IOException("Stream is closed"); this.waitUntilNotFull(); // Put the byte. this.buffer.put(this.tail, (byte) b); this.tail = (this.tail + 1) % this.capacity; this.state = this.tail == this.head ? State.FULL : State.PART; // Wake up the background thread. this.notEmpty.signal(); } finally { this.lock.unlock(); } }
try { while (this.state != State.CLOSED) { this.waitUntilNotEmpty();
private void waitUntilNotFull() throws IOException { try { while (this.state == State.FULL) this.notFull.await(); } catch (InterruptedException ie) { throw new InterruptedIOException(); // SUPPRESS CHECKSTYLE AvoidHidingCause } this.checkException(); }
@Override public void flush() throws IOException { this.lock.lock(); try { if (this.state == State.CLOSED) throw new IOException("Stream is closed"); this.waitUntilEmpty(); this.out.flush(); } finally { this.lock.unlock(); } }
@Override public void close() throws IOException { this.lock.lock(); try { this.flush(); this.state = State.CLOSED; this.buffer = null; this.out.close(); this.notEmpty.signal(); } finally { this.lock.unlock(); } }
private void waitUntilNotEmpty() throws IOException { try { while (this.state == State.EMPTY) this.notEmpty.await(); } catch (InterruptedException e) { throw new InterruptedIOException(); // SUPPRESS CHECKSTYLE AvoidHidingCause } this.checkException(); }
private void waitUntilNotFull() throws IOException { try { while (this.state == State.FULL) this.notFull.await(); } catch (InterruptedException ie) { throw new InterruptedIOException(); // SUPPRESS CHECKSTYLE AvoidHidingCause } this.checkException(); }
private void waitUntilEmpty() throws IOException { try { while (this.state != State.EMPTY) this.notFull.await(); } catch (InterruptedException ie) { throw new InterruptedIOException(); // SUPPRESS CHECKSTYLE AvoidHidingCause } this.checkException(); }
private void waitUntilNotEmpty() throws IOException { try { while (this.state == State.EMPTY) this.notEmpty.await(); } catch (InterruptedException e) { throw new InterruptedIOException(); // SUPPRESS CHECKSTYLE AvoidHidingCause } this.checkException(); }