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

36
LINES

< > BotCompany Repo | #1011912 // _registerDangerousWeakMap - register a weak map to be cleared regularly, automatically

JavaX fragment (include)

1  
static L<Pair> _registerDangerousWeakMap_preList;
2  
3  
static <A> A _registerDangerousWeakMap(A map) {
4  
  ret _registerDangerousWeakMap(map, null);
5  
}
6  
7  
static <A> A _registerDangerousWeakMap(A map, O init) {
8  
  ifndef LeanMode
9  
  callF(init, map);
10  
  
11  
  if (init instanceof S) {
12  
    fS f = cast init;
13  
    init = voidfunc(Map map) { callMC(f, map) };
14  
  }
15  
    
16  
  if (javax() == null) {
17  
    // We're in class init
18  
    if (_registerDangerousWeakMap_preList == null) _registerDangerousWeakMap_preList = synchroList();
19  
    _registerDangerousWeakMap_preList.add(pair(map, init));
20  
    ret map;
21  
  }
22  
  
23  
  call(javax(), '_registerDangerousWeakMap, map, init);
24  
  endifndef
25  
  ret map;
26  
}
27  
28  
static void _onLoad_registerDangerousWeakMap() {
29  
  ifndef LeanMode
30  
  assertNotNull(javax());
31  
  if (_registerDangerousWeakMap_preList == null) ret;
32  
  for (Pair p : _registerDangerousWeakMap_preList)
33  
    _registerDangerousWeakMap(p.a, p.b);
34  
  _registerDangerousWeakMap_preList = null;
35  
  endifndef
36  
}

Author comment

Began life as a copy of #1010619

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011912
Snippet name: _registerDangerousWeakMap - register a weak map to be cleared regularly, automatically
Eternal ID of this version: #1011912/7
Text MD5: 96aaef76b8866f3e37e6b5fd51003146
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-22 22:50:05
Source code size: 997 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 521 / 636
Version history: 6 change(s)
Referenced in: [show references]