Example usage for io.vertx.core.buffer Buffer slice

List of usage examples for io.vertx.core.buffer Buffer slice

Introduction

In this page you can find the example usage for io.vertx.core.buffer Buffer slice.

Prototype

Buffer slice();

Source Link

Document

Returns a slice of this buffer.

Usage

From source file:com.hubrick.vertx.s3.util.ChunkedBufferReadStream.java

License:Apache License

private void writeChunk(boolean resumed) {
    if (!paused) {
        try {/*from w w  w .ja  v  a 2 s  .c  o  m*/
            while (!lastChunks.isEmpty()) {
                final Buffer currentChunk = lastChunks.pop();
                if (currentChunk.length() > 0) {
                    if (handler != null) {
                        handler.handle(currentChunk.slice());
                    }
                }
            }

            if (endCalled && !endHandled) {
                endHandled = true;
                if (endHandler != null) {
                    endHandler.handle(null);
                }
            }
        } catch (Throwable t) {
            pause();
            if (exceptionHandler != null) {
                exceptionHandler.handle(t);
            }
        }
    } else if (resumed) {
        writeChunkAsync(resumed);
    }
}