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

15
LINES

< > BotCompany Repo | #1031638 - tempSetThreadLocalIfNecessary - compares with existing value first

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

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

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

static <A> AutoCloseable tempSetThreadLocalIfNecessary(x30_pkg.x30_util.BetterThreadLocal<A> tl, A a) {
  if (tl == null) null;
  A prev = tl.get();
  if (eq(prev, a)) null;
  tl.set(a);
  ret autoCloseable { tl.set(prev); };
}

Author comment

Began life as a copy of #1012933

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1031638
Snippet name: tempSetThreadLocalIfNecessary - compares with existing value first
Eternal ID of this version: #1031638/4
Text MD5: 94b4687c39a8e6f23d6cdd7fcc6c455b
Transpilation MD5: 63c312a224f0e4b0d9363bcff279cbdb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-27 00:10:56
Source code size: 447 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 21 / 56
Version history: 3 change(s)
Referenced in: [show references]

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