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

32
LINES

< > BotCompany Repo | #1014020 - mechList_raw

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

Libraryless. Click here for Pure Java version (5763L/40K).

static ExpiringMap2<S, S> mechList_raw_cache = new ExpiringMap2(10000).setMap(ciMap());
static Lock mechList_raw_lock = lock();

// timeout for loading
static int mechList_raw_timeout = 60000;

static S mechList_raw(S name) ctex {
  lock mechList_raw_lock;
  
  if (empty(name)) ret "";
  
  // get from cache
  S src = mechList_raw_cache.get(name);
  if (src != null) ret src;
  
  // load & put in cache - TODO: make postPage honor this
  //temp tempSetThreadLocal(loadPage_forcedTimeout_byThread, mechList_raw_timeout);
  src = mechList_raw_fresh(name);
  if (src != null)
    mechList_raw_cache.put(name, src);
  ret src;
}

static VF2<S, O> mechList_raw_listener = voidfunc(S msg, O arg) {
  if (eq(msg, 'mechChange) && arg instanceof S) {
    //print("Got change notification: " + arg);
    mechList_raw_cache.remove((S) arg);
  }
};

svoid _onLoad_mechList_raw { add(vm_busListeners_live(), mechList_raw_listener); }
svoid cleanMeUp_mechList_raw { remove(vm_busListeners_live(), mechList_raw_listener); }

download  show line numbers  debug dex   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lnbujpyubztb, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1014020
Snippet name: mechList_raw
Eternal ID of this version: #1014020/26
Text MD5: 04207ded10b7976180564abfb40a2f14
Transpilation MD5: 88509b641d558a68e7e4896bd3a0de21
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-21 11:21:24
Source code size: 1042 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 322 / 411
Version history: 25 change(s)
Referenced in: [show references]

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