src/main/java/com/wizzardo/epoll/Connection.java
public boolean write(ByteBufferProvider bufferProvider) {
        Queue<ReadableData> queue = this.sending;
        if (queue == null)
            return true;

        while (!queue.isEmpty() && writer.compareAndSet(null, bufferProvider)) {
            try {
                ReadableData readable;
                while ((readable = queue.peek()) != null) {
                    while (!readable.isComplete() && actualWrite(readable, bufferProvider)) {
                    }
                    if (!readable.isComplete())
                        return false;

                    queue.poll();
                    readable.close();
                    readable.onComplete();
                    onWriteData(readable, !queue.isEmpty());
                }
            } catch (Exception e) {
                e.printStackTrace();
                close();
                return false;
            } finally {
                writer.set(null);
            }
        }
        return true;
    }
public boolean write(ByteBufferProvider bufferProvider) {
        Queue<ReadableData> queue = this.sending;
        if (queue == null)
            return true;

        while (!queue.isEmpty() && writer.compareAndSet(null, bufferProvider)) {
            try {
                ReadableData readable;
                while ((readable = queue.peek()) != null) {
                    while (!readable.isComplete() && actualWrite(readable, bufferProvider)) {
                    }
                    if (!readable.isComplete())
                        return false;

                    queue.poll();
                    readable.close();
                    readable.onComplete();
                    onWriteData(readable, !queue.isEmpty());
                }
            } catch (Exception e) {
                e.printStackTrace();
                close();
                return false;
            } finally {
                writer.set(null);
            }
        }
        return true;
    }
/*
@return true if connection is ready to write data