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)

static L<Pair> _registerDangerousWeakMap_preList;

static <A> A _registerDangerousWeakMap(A map) {
  ret _registerDangerousWeakMap(map, null);
}

static <A> A _registerDangerousWeakMap(A map, O init) {
  ifndef LeanMode
  callF(init, map);
  
  if (init instanceof S) {
    fS f = cast init;
    init = voidfunc(Map map) { callMC(f, map) };
  }
    
  if (javax() == null) {
    // We're in class init
    if (_registerDangerousWeakMap_preList == null) _registerDangerousWeakMap_preList = synchroList();
    _registerDangerousWeakMap_preList.add(pair(map, init));
    ret map;
  }
  
  call(javax(), '_registerDangerousWeakMap, map, init);
  endifndef
  ret map;
}

static void _onLoad_registerDangerousWeakMap() {
  ifndef LeanMode
  assertNotNull(javax());
  if (_registerDangerousWeakMap_preList == null) ret;
  for (Pair p : _registerDangerousWeakMap_preList)
    _registerDangerousWeakMap(p.a, p.b);
  _registerDangerousWeakMap_preList = null;
  endifndef
}

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: 522 / 637
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)