1 | static new HashSet<S> fillVar_set; |
2 | |
3 | // make: func -> var type; or a class |
4 | // TODO: better synchronisation |
5 | // also, might return null while var is filled by another thread |
6 | static O fillVar(S var, O make) { |
7 | synchronized(fillVar_set) { |
8 | if (fillVar_set.contains(var)) ret get(mc(), var); |
9 | fillVar_set.add(var); |
10 | } |
11 | O o = make instanceof Class ? nuInstance((Class) make) : callF(make); |
12 | set(mc(), var, o); |
13 | synchronized(fillVar_set) {} // sync? |
14 | ret o; |
15 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009045 |
Snippet name: | fillVar - fill a global variable in a synchronized way. does it only once |
Eternal ID of this version: | #1009045/3 |
Text MD5: | 003c2d502230173d80c692d404fc53a8 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-07-24 17:43:54 |
Source code size: | 477 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 527 / 574 |
Version history: | 2 change(s) |
Referenced in: | [show references] |