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

24
LINES

< > BotCompany Repo | #1017055 // evalJava_prep2 - actually makes & loads the code

JavaX fragment (include)

scope evalJava_prep2.

// flag is per thread, cache is per program (in-memory cache of JavaX source -> loaded Class)
static new ThreadLocal<Bool> #useCacheInThread;
static volatile bool #useCache;

// cached main classes, used only when you enable it
static Map<S, O> #cache = synchronizedMRUCache(100);

static O evalJava_prep2(S main) {
  bool _useCache = useCache || isTrue(useCacheInThread!);
  if (_useCache) {
    O obj = cache.get(main);
    if (obj != null) ret obj;
  }
  O obj = veryQuickJava(main);
  if (_useCache)
    cache.put(main, obj);
  makeDependent(obj);
  setOpt(obj, "getProgramName_cache", "User Code");
  ret obj;
}

end scope

Author comment

Began life as a copy of #1011860

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: #1017055
Snippet name: evalJava_prep2 - actually makes & loads the code
Eternal ID of this version: #1017055/13
Text MD5: f14245e976f5de285eb1c3431647a05b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-22 12:46:13
Source code size: 673 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 388 / 437
Version history: 12 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)