private void onDrain() {
        for (int i = 0; i < this.prevBufferLen; i++) {
            Runnable callback = this.callbackBuffer.get(i);
            if (callback != null) {
                callback.run();
            }
        }

        for (int i = 0; i < this.prevBufferLen; i++) {
            this.writeBuffer.poll();
            this.callbackBuffer.poll();
        }

        this.prevBufferLen = 0;
        if (this.writeBuffer.size() == 0) {
            this.emit(EVENT_DRAIN);
        } else {
            this.flush();
        }
    }