Warning: session_start(): open(/var/lib/php/sessions/sess_h1at9eilqve2gscdl5uioi4ddg, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
cprint FreezeStackDemo {
transient bool shouldFreeze;
start-thread {
print(myFunc(5));
print(myFunc_v2(5));
set shouldFreeze;
myFunc_v2(5);
}
S myFunc(int n) {
if (n >= 100) n = 100;
if (n <= 0) ret "base";
ret n + " " + myFunc(n-1);
}
class FreezeStackException extends Exception {
new L stack;
void add(O entry) { stack.add(entry); }
}
srecord myFunc_vstack(int n) implements VStack.Computable {
public void step(VStack stack, O subResult) {
if (vstack.hasSubResult())
ret n + " " + subResult;
else {
if (n >= 100) n = 100;
if (n <= 0) stack._return("base+");
stack.push(new myFunc_vstack(n-1));
}
}
}
S myFunc_v2(int n) throws FreezeStackException {
try {
if (n >= 100) n = 100;
if (n <= 0) if (shouldFreeze) throw freezeStack(); else ret "base";
ret n + " " + myFunc(n-1);
} on fail FreezeStackException e {
e.add(new myFunc_vstack(n));
}
}
FreezeStackException freezeStack() throws FreezeStackException {
throw new FreezeStackException;
}
}