Java 类io.netty.util.concurrent.FastThreadLocal 实例源码

项目:sstable-adaptor    文件:DeflateCompressor.java   
private DeflateCompressor()
{
    deflater = new FastThreadLocal<Deflater>()
    {
        @Override
        protected Deflater initialValue()
        {
            return new Deflater();
        }
    };
    inflater = new FastThreadLocal<Inflater>()
    {
        @Override
        protected Inflater initialValue()
        {
            return new Inflater();
        }
    };
}
项目:sstable-adaptor    文件:NamedThreadFactory.java   
/**
 * Ensures that {@link FastThreadLocal#remove() FastThreadLocal.remove()} is called when the {@link Runnable#run()}
 * method of the given {@link Runnable} instance completes to ensure cleanup of {@link FastThreadLocal} instances.
 * This is especially important for direct byte buffers allocated locally for a thread.
 */
public static Runnable threadLocalDeallocator(Runnable r)
{
    return () ->
    {
        try
        {
            r.run();
        }
        finally
        {
            FastThreadLocal.removeAll();
        }
    };
}
项目:firebase-admin-java    文件:RepoManager.java   
public static void destroy(Context ctx) {
  try {
    instance.destroyInternal(ctx);
  } finally {
    ctx.stop();
    // Clean up Netty thread locals, which will also clean up any dangling threadDeathWatcher
    // daemons. See https://github.com/netty/netty/issues/7310 for more context.
    FastThreadLocal.removeAll();
  }
}
项目:saluki    文件:NamedThreadFactory.java   
@Override
public void run() {
    try {
        r.run();
    } finally {
        FastThreadLocal.removeAll();
    }
}
项目:graphiak    文件:ChannelFutureManager.java   
@Override
public void stop() throws Exception {
    future.channel().closeFuture();
    // clean up internal Netty threads
    FastThreadLocal.removeAll();
    FastThreadLocal.destroy();
}
项目:uploader    文件:ChannelFutureManager.java   
@Override
public void stop() throws Exception {
    future.channel().closeFuture();
    // clean up internal Netty threads
    FastThreadLocal.removeAll();
    FastThreadLocal.destroy();
}
项目:LanternServer    文件:FastThreadLocals.java   
public static <S> FastThreadLocal<S> withInitial(Supplier<? extends S> supplier) {
    checkNotNull(supplier, "supplier");
    return new FastThreadLocal<S>() {
        @Override
        protected S initialValue() throws Exception {
            return supplier.get();
        }
    };
}
项目:LanternServer    文件:FastSoftThreadLocal.java   
private static <T> FastThreadLocal<SoftReference<T>> create(Supplier<? extends T> supplier) {
    requireNonNull(supplier);
    return FastThreadLocals.withInitial(() -> {
        final T value = supplier.get();
        return value == null ? null : new SoftReference<>(value);
    });
}
项目:netty4.0.27Learn    文件:FastThreadLocalBenchmark.java   
@Benchmark
public int fastThreadLocal() {
    int result = 0;
    for (FastThreadLocal<Integer> i: fastThreadLocals) {
        result += i.get();
    }
    return result;
}
项目:RxS3    文件:AWSSignatureCalculatorFactory.java   
public AWSSignatureCalculatorFactory(AWSCredentialsProvider credentialsProvider) {
    signatureCalculator = new FastThreadLocal<AWSSignatureCalculator>() {
        @Override
        protected AWSSignatureCalculator initialValue() {
            return new AWSSignatureCalculator(credentialsProvider);
        }
    };
}
项目:LanternServer    文件:FastSoftThreadLocal.java   
private FastSoftThreadLocal(FastThreadLocal<SoftReference<T>> threadLocal) {
    this.threadLocal = threadLocal;
}
项目:LanternServer    文件:FastSoftThreadLocal.java   
/**
 * Creates a thread local variable.
 *
 * @see #withInitial(Supplier)
 */
public FastSoftThreadLocal() {
    this(new FastThreadLocal<>());
}