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; }
public static InternalThreadLocalMap get() { Thread thread = Thread.currentThread(); if (thread instanceof FastThreadLocalThread) { return fastGet((FastThreadLocalThread) thread); } else { return slowGet(); } }
private static InternalThreadLocalMap fastGet(FastThreadLocalThread thread) { InternalThreadLocalMap threadLocalMap = thread.threadLocalMap(); if (threadLocalMap == null) { thread.setThreadLocalMap(threadLocalMap = new InternalThreadLocalMap()); } return threadLocalMap; }
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(); } } }
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()); }
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; }
protected Thread newThread(Runnable r, String name) { return new FastThreadLocalThread(threadGroup, r, name); }