static new HashSet<S> fillVar_set; // make: func -> var type; or a class // TODO: better synchronisation // also, might return null while var is filled by another thread static O fillVar(S var, O make) { synchronized(fillVar_set) { if (fillVar_set.contains(var)) ret get(mc(), var); fillVar_set.add(var); } O o = make instanceof Class ? nuInstance((Class) make) : callF(make); set(mc(), var, o); synchronized(fillVar_set) {} // sync? ret o; }
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: | 526 / 572 |
Version history: | 2 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |