You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
655 B

var thread;
var res;
/*===
123
===*/
/* Calling via Function.prototype.call() or Function.prototype.apply() would
* prevent a yield().
*/
function innerfunc() {
__duk__.yield(123);
}
function coroutine1() {
// This is a native call so naive handling would prevent a later yield
innerfunc.call();
}
function coroutine2() {
// Same here
innerfunc.apply();
}
try {
thread = __duk__.spawn(coroutine1);
res = __duk__.resume(thread, 0);
print(res);
} catch (e) {
print(e.name);
}
try {
thread = __duk__.spawn(coroutine2);
res = __duk__.resume(thread, 0);
print(res);
} catch (e) {
print(e.name);
}