mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-23 22:27:28 +00:00
perf[thread]: fast thread local adapter
This commit is contained in:
@@ -13,6 +13,10 @@ public class FastThreadLocalAdapter<T> {
|
||||
|
||||
private Supplier<T> supplier;
|
||||
|
||||
public FastThreadLocalAdapter() {
|
||||
this.fastThreadLocal = new FastThreadLocal<>();
|
||||
}
|
||||
|
||||
public FastThreadLocalAdapter(Supplier<T> supplier) {
|
||||
this.supplier = supplier;
|
||||
this.fastThreadLocal = new FastThreadLocal<>() {
|
||||
@@ -27,4 +31,9 @@ public class FastThreadLocalAdapter<T> {
|
||||
// return Thread.currentThread().isVirtual() ? supplier.get() : fastThreadLocal.get();
|
||||
return fastThreadLocal.get();
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
fastThreadLocal.set(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user