@Override
    public void write(ByteBuffer buf, CompletionHandler handler) {
        ContentChannel content;
        synchronized (lock) {
            if (closed) {
                throw new IllegalStateException();
            }
            if (queue != null) {
                queue.add(new Entry(buf, handler));
                return;
            }
            try {
                while (this.content == null) {
                    lock.wait(); // waiting for connectTo()
                }
            } catch (InterruptedException e) {
                throw new IllegalStateException(e);
            }
            if (closed) {
                throw new IllegalStateException();
            }
            content = this.content;
        }
        content.write(buf, handler);
    }
<p>Creates a {@link ContentInputStream} and {@link #connectTo(ContentChannel) connects} to its internal
ContentChannel.</p>

@return The new ContentInputStream that this connected to.
jdisc_core/src/main/java/com/yahoo/jdisc/handler/BufferedContentChannel.java