All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.firefly.net.MergedOutputEntry Maven / Gradle / Ivy

There is a newer version: 5.0.0-dev6
Show newest version
package com.firefly.net;

import com.firefly.utils.concurrent.Callback;
import com.firefly.utils.io.BufferUtils;

import java.nio.ByteBuffer;
import java.util.List;

import static com.firefly.net.OutputEntryType.MERGED_BUFFER;

/**
 * @author Pengtao Qiu
 */
public class MergedOutputEntry extends AbstractByteBufferArrayOutputEntry {

    public MergedOutputEntry(List callbackList, List byteBufferList) {
        super(new Callback() {
            @Override
            public void succeeded() {
                callbackList.forEach(Callback::succeeded);
            }

            @Override
            public void failed(Throwable x) {
                callbackList.forEach(c -> c.failed(x));
            }
        }, byteBufferList.toArray(BufferUtils.EMPTY_BYTE_BUFFER_ARRAY));
    }

    @Override
    public OutputEntryType getOutputEntryType() {
        return MERGED_BUFFER;
    }

    @Override
    public long remaining() {
        return BufferUtils.remaining(data);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy