Example usage for io.netty.util.concurrent FastThreadLocalThread FastThreadLocalThread

List of usage examples for io.netty.util.concurrent FastThreadLocalThread FastThreadLocalThread

Introduction

In this page you can find the example usage for io.netty.util.concurrent FastThreadLocalThread FastThreadLocalThread.

Prototype

public FastThreadLocalThread(String name) 

Source Link

Usage

From source file:org.apache.cassandra.streaming.compress.CompressedInputStream.java

License:Apache License

/**
 * @param source Input source to read compressed data from
 * @param info Compression info/*from w  ww. ja  va2 s.co  m*/
 */
public CompressedInputStream(InputStream source, CompressionInfo info, ChecksumType checksumType,
        Supplier<Double> crcCheckChanceSupplier) {
    this.info = info;
    this.buffer = new byte[info.parameters.chunkLength()];
    // buffer is limited to store up to 1024 chunks
    this.dataBuffer = new ArrayBlockingQueue<>(Math.min(info.chunks.length, 1024));
    this.crcCheckChanceSupplier = crcCheckChanceSupplier;
    this.checksumType = checksumType;

    new FastThreadLocalThread(new Reader(source, info, dataBuffer)).start();
}

From source file:org.lanternpowered.server.util.ThreadHelper.java

License:MIT License

private static Thread newFastThreadLocalThread0(Consumer<Thread> runnable, @Nullable String name) {
    requireNonNull(runnable, "runnable");
    final Consumer<Thread> runnable1 = thread0 -> {
        try {/*from ww  w.ja v a 2 s .co m*/
            runnable.accept(thread0);
        } finally {
            FastThreadLocal.removeAll();
        }
    };
    final Thread thread;
    if (name != null) {
        thread = new FastThreadLocalThread(name) {
            @Override
            public void run() {
                runnable1.accept(this);
            }
        };
    } else {
        thread = new FastThreadLocalThread() {
            @Override
            public void run() {
                runnable1.accept(this);
            }
        };
    }
    return thread;
}