Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1030297 - FlexThreadLocal - more flexible version of BetterThreadLocal [for inheriting threadlocals in thread pools]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2581L/16K).

sclass FlexThreadLocal<A> extends BetterThreadLocal<A> {
  static Map<Thread> motherThreads = weakMap();

  public A get() {
    ret get(grandMotherThread());
  }
  
  void set(A a) {
    map.put(grandMotherThread(), a);
  }
  
  static Thread grandMotherThread(Thread t default currentThread()) {
    ret applyWhileNotNull motherThread(t);
  }
  
  static void setMotherThread(Thread t) {
    mapPutOrRemove(motherThreads, currentThread(), grandMotherThread(t));
  }
  
  static Thread motherThread(Thread t default currentThread()) {
    ret mapGet(motherThreads, t);
  }
}

download  show line numbers  debug dex   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

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: 26 / 66
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1030297 & http://1030297.tinybrain.de