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

7
LINES

< > BotCompany Repo | #1031639 // tempSetThreadLocalIfNecessary_weakRef - compares with existing value first. wraps value in WeakReference

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

Libraryless. Click here for Pure Java version (62L/1K).

static <A> AutoCloseable tempSetThreadLocalIfNecessary_weakRef(ThreadLocal<WeakReference> tl, A a) {
  if (tl == null) null;
  WeakReference prev = tl.get();
  if (eq(getWeakRef(prev), a)) null;
  tl.set(weakRef(a));
  ret autoCloseable { tl.set(prev); };
}

Author comment

Began life as a copy of #1031638

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031639
Snippet name: tempSetThreadLocalIfNecessary_weakRef - compares with existing value first. wraps value in WeakReference
Eternal ID of this version: #1031639/3
Text MD5: 9504667ace5fd39ab4b8035120381474
Transpilation MD5: 7b54d7181d9457f8923cbdc932b9db68
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-24 22:54:47
Source code size: 263 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 204 / 259
Version history: 2 change(s)
Referenced in: [show references]