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

项目:netty4.0.27Learn    文件:InternalThreadLocalMap.java   
public static InternalThreadLocalMap getIfSet() {
    Thread thread = Thread.currentThread();
    InternalThreadLocalMap threadLocalMap;
    if (thread instanceof FastThreadLocalThread) {
        threadLocalMap = ((FastThreadLocalThread) thread).threadLocalMap();
    } else {
        ThreadLocal<InternalThreadLocalMap> slowThreadLocalMap = UnpaddedInternalThreadLocalMap.slowThreadLocalMap;
        if (slowThreadLocalMap == null) {
            threadLocalMap = null;
        } else {
            threadLocalMap = slowThreadLocalMap.get();
        }
    }
    return threadLocalMap;
}
项目:netty4.0.27Learn    文件:InternalThreadLocalMap.java   
public static InternalThreadLocalMap get() {
    Thread thread = Thread.currentThread();
    if (thread instanceof FastThreadLocalThread) {
        return fastGet((FastThreadLocalThread) thread);
    } else {
        return slowGet();
    }
}
项目:netty4.0.27Learn    文件:InternalThreadLocalMap.java   
private static InternalThreadLocalMap fastGet(FastThreadLocalThread thread) {
    InternalThreadLocalMap threadLocalMap = thread.threadLocalMap();
    if (threadLocalMap == null) {
        thread.setThreadLocalMap(threadLocalMap = new InternalThreadLocalMap());
    }
    return threadLocalMap;
}
项目:netty4.0.27Learn    文件:InternalThreadLocalMap.java   
public static void remove() {
    Thread thread = Thread.currentThread();
    if (thread instanceof FastThreadLocalThread) {
        ((FastThreadLocalThread) thread).setThreadLocalMap(null);
    } else {
        ThreadLocal<InternalThreadLocalMap> slowThreadLocalMap = UnpaddedInternalThreadLocalMap.slowThreadLocalMap;
        if (slowThreadLocalMap != null) {
            slowThreadLocalMap.remove();
        }
    }
}
项目:armeria    文件:Server.java   
private ChannelFuture start(ServerPort port) {
    final ServerBootstrap b = new ServerBootstrap();

    b.group(EventLoopGroups.newEventLoopGroup(1, r -> {
        final FastThreadLocalThread thread = new FastThreadLocalThread(r, bossThreadName(port));
        thread.setDaemon(false);
        return thread;
    }), config.workerGroup());
    b.channel(TransportType.detectTransportType().serverChannelClass());
    b.handler(connectionLimitingHandler);
    b.childHandler(new HttpServerPipelineConfigurator(config, port, sslContexts, gracefulShutdownSupport));

    return b.bind(port.localAddress());
}
项目:sstable-adaptor    文件:NamedThreadFactory.java   
public static Thread createThread(ThreadGroup threadGroup, Runnable runnable, String name, boolean daemon)
{
    Thread thread = new FastThreadLocalThread(threadGroup, threadLocalDeallocator(runnable), name);
    thread.setDaemon(daemon);
    return thread;
}
项目:saluki    文件:NamedThreadFactory.java   
protected Thread newThread(Runnable r, String name) {
    return new FastThreadLocalThread(threadGroup, r, name);
}