Download Jar. Uses 3874K of libraries. Compilation Failed (7508L/51K).
!7 p-experiment { callHibernatable(f normalFunction1); callHibernatable(f hibernatingFunction1); /*for (bool hibernate : ll(false, true)) { callHibernatable(curry(f aFunction, hibernate), voidfunc(S s) { print("Got result: " + finished); }); }*/ } // simple version with only one function and no return value static void callHibernatable(O f1) { try { callF(f1); } catch (RuntimeException e) { Throwable e2 = innerException(e); if (e2 instanceof HibernatingTheThread) ret; throw rethrow(e2); } } static O callHibernatable(O f1, O f2) { O result; try { result = callF(f1); } catch (RuntimeException e) { Throwable e2 = innerException(e); if (!e2 instanceof HibernatingTheThread) throw rethrow(e); HibernatingTheThread h = cast e2; throw HibernatingTheThread(func { }); } ret callF(f2, result); } svoid normalFunction1() { print("finished"); } svoid hibernatingFunction1() { HibernatingTheThread e = new(r { print("finished after hibernation"); }); doLater(1000, e); throw e; } sS aFunction(bool hibernate) { if (hibernate) { print("Hibernating for 1s..."); HibernatingTheThread e = new(func -> S { ret "finished"; }); doLater(1000, e); throw e; } else ret "hello"; } sclass HibernatingTheThread extends RuntimeException implements Runnable { O code; // runnable or F0 O continuation; // runnable or vf1 *() {} *(O *code) {} public void run() { callF(continuation, callF(code)); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1015709 |
Snippet name: | Thread Hibernation Spike v1 [dev.] |
Eternal ID of this version: | #1015709/10 |
Text MD5: | f8b5ed553d1fec0dbea3009c3496e668 |
Transpilation MD5: | 870b78a6f7c8b5ee0ab1d3981f7ee2ae |
Author: | stefan |
Category: | |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-24 16:05:01 |
Source code size: | 1611 bytes / 72 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 470 / 1032 |
Version history: | 9 change(s) |
Referenced in: | [show references] |