Libraryless. Click here for Pure Java version (2581L/16K).
1 | sclass FlexThreadLocal<A> extends BetterThreadLocal<A> { |
2 | static Map<Thread> motherThreads = weakMap(); |
3 | |
4 | public A get() { |
5 | ret get(grandMotherThread()); |
6 | } |
7 | |
8 | void set(A a) { |
9 | map.put(grandMotherThread(), a); |
10 | } |
11 | |
12 | static Thread grandMotherThread(Thread t default currentThread()) { |
13 | ret applyWhileNotNull motherThread(t); |
14 | } |
15 | |
16 | static void setMotherThread(Thread t) { |
17 | mapPutOrRemove(motherThreads, currentThread(), grandMotherThread(t)); |
18 | } |
19 | |
20 | static Thread motherThread(Thread t default currentThread()) { |
21 | ret mapGet(motherThreads, t); |
22 | } |
23 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030297 |
Snippet name: | FlexThreadLocal - more flexible version of BetterThreadLocal [for inheriting threadlocals in thread pools] |
Eternal ID of this version: | #1030297/6 |
Text MD5: | eaa608a71e198a9db416aaef607a408d |
Transpilation MD5: | f45a82375bf73bbf8c9d1e99d5b7a832 |
Author: | stefan |
Category: | javax / threads |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-11-28 00:05:28 |
Source code size: | 597 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 232 / 484 |
Version history: | 5 change(s) |
Referenced in: | [show references] |