Libraryless. Click here for Pure Java version (10184L/74K).
1 | static HashMap<Set<S>, Class> loadFunctions_cache = new HashMap; |
2 | static Lock loadFunctions_cached_lock = lock(); |
3 | |
4 | sbool loadFunctions_preferDiskCache; // Note: This may use outdated versions of standard functions |
5 | |
6 | static Class loadFunctions_cached(S... functions) {
|
7 | ret loadFunctions_cached(asList(functions)); |
8 | } |
9 | |
10 | static Class loadFunctions_cached(Collection<S> functions) {
|
11 | TreeSet<S> functionSet = new TreeSet<S>(functions); |
12 | lock loadFunctions_cached_lock; |
13 | Class c = loadFunctions_cache.get(functionSet); |
14 | if (c != null) ret c; |
15 | S transpilation = null; |
16 | |
17 | // new mode for slow machines (Raspberry Pi): get server transpilation |
18 | if (l(functions) == 1 && isSlowMachine()) {
|
19 | S snippetID = stdFunctions_cached().get(first(functions)); |
20 | if (nempty(snippetID)) {
|
21 | if (!isMD5(getUpToDateSnippetTranspilationMD5(snippetID))) |
22 | print("Slow machine mode: " + snippetID + " transpilation not up to date");
|
23 | else {
|
24 | transpilation = getServerTranspiledWithoutLibs(snippetID); // TODO: libs? |
25 | print("Loaded server transpilation: " + snippetID);
|
26 | } |
27 | } |
28 | } |
29 | |
30 | if (transpilation == null) {
|
31 | S cached = getTranspiledStandardFunctionsIfCached(functionSet); |
32 | // TODO: make sure we're using an up-to-date transpiler too |
33 | if (cached != null && (loadFunctions_preferDiskCache || standardFunctionsCacheUpToDate(functionSet))) |
34 | transpilation = cached; |
35 | } |
36 | if (transpilation != null) {
|
37 | // TODO: LIBS |
38 | print("Loading " + joinWithPlus(functionSet));
|
39 | c = veryQuickJava_finish(transpilation, emptyList()); |
40 | } |
41 | |
42 | if (c == null) c = loadFunctions(functionSet); |
43 | |
44 | loadFunctions_cache.put(functionSet, c); |
45 | assertNotNull(loadFunctions_cache.get(functionSet)); |
46 | ret c; |
47 | } |
48 | |
49 | svoid loadFunctions_cached_clearCache() {
|
50 | lock loadFunctions_cached_lock; |
51 | loadFunctions_cache.clear(); |
52 | } |
53 | |
54 | svoid _onLoad_loadFunctions_cached {
|
55 | ownResource(vmBus_onMessage('refreshedTranspiler, r loadFunctions_clearCache));
|
56 | } |
Began life as a copy of #1007852
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1007946 |
| Snippet name: | loadFunctions_cached |
| Eternal ID of this version: | #1007946/25 |
| Text MD5: | a0820ecc7bdc2bc726ee8bda851ee863 |
| Transpilation MD5: | 61b70f145fddc77d6262ab1d6219a823 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-02-12 19:44:57 |
| Source code size: | 2019 bytes / 56 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 971 / 1135 |
| Version history: | 24 change(s) |
| Referenced in: | [show references] |