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)

1  
scope evalJava_prep2.
2  
3  
// flag is per thread, cache is per program (in-memory cache of JavaX source -> loaded Class)
4  
static new ThreadLocal<Bool> #useCacheInThread;
5  
static volatile bool #useCache;
6  
7  
// cached main classes, used only when you enable it
8  
static Map<S, O> #cache = synchronizedMRUCache(100);
9  
10  
static O evalJava_prep2(S main) {
11  
  bool _useCache = useCache || isTrue(useCacheInThread!);
12  
  if (_useCache) {
13  
    O obj = cache.get(main);
14  
    if (obj != null) ret obj;
15  
  }
16  
  O obj = veryQuickJava(main);
17  
  if (_useCache)
18  
    cache.put(main, obj);
19  
  makeDependent(obj);
20  
  setOpt(obj, "getProgramName_cache", "User Code");
21  
  ret obj;
22  
}
23  
24  
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: 318 / 374
Version history: 12 change(s)
Referenced in: [show references]