1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.util.concurrent;
17
18 import io.netty.util.internal.InternalThreadLocalMap;
19 import io.netty.util.internal.UnstableApi;
20
21
22
23
24 public class FastThreadLocalThread extends Thread {
25
26 private final boolean cleanupFastThreadLocals;
27
28 private InternalThreadLocalMap threadLocalMap;
29
30 public FastThreadLocalThread() {
31 cleanupFastThreadLocals = false;
32 }
33
34 public FastThreadLocalThread(Runnable target) {
35 super(FastThreadLocalRunnable.wrap(target));
36 cleanupFastThreadLocals = true;
37 }
38
39 public FastThreadLocalThread(ThreadGroup group, Runnable target) {
40 super(group, FastThreadLocalRunnable.wrap(target));
41 cleanupFastThreadLocals = true;
42 }
43
44 public FastThreadLocalThread(String name) {
45 super(name);
46 cleanupFastThreadLocals = false;
47 }
48
49 public FastThreadLocalThread(ThreadGroup group, String name) {
50 super(group, name);
51 cleanupFastThreadLocals = false;
52 }
53
54 public FastThreadLocalThread(Runnable target, String name) {
55 super(FastThreadLocalRunnable.wrap(target), name);
56 cleanupFastThreadLocals = true;
57 }
58
59 public FastThreadLocalThread(ThreadGroup group, Runnable target, String name) {
60 super(group, FastThreadLocalRunnable.wrap(target), name);
61 cleanupFastThreadLocals = true;
62 }
63
64 public FastThreadLocalThread(ThreadGroup group, Runnable target, String name, long stackSize) {
65 super(group, FastThreadLocalRunnable.wrap(target), name, stackSize);
66 cleanupFastThreadLocals = true;
67 }
68
69
70
71
72
73 public final InternalThreadLocalMap threadLocalMap() {
74 return threadLocalMap;
75 }
76
77
78
79
80
81 public final void setThreadLocalMap(InternalThreadLocalMap threadLocalMap) {
82 this.threadLocalMap = threadLocalMap;
83 }
84
85
86
87
88 @UnstableApi
89 public boolean willCleanupFastThreadLocals() {
90 return cleanupFastThreadLocals;
91 }
92
93
94
95
96 @UnstableApi
97 public static boolean willCleanupFastThreadLocals(Thread thread) {
98 return thread instanceof FastThreadLocalThread &&
99 ((FastThreadLocalThread) thread).willCleanupFastThreadLocals();
100 }
101 }