mirror of https://github.com/svaarala/duktape.git
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.
47 lines
736 B
47 lines
736 B
/*---
|
|
{
|
|
"custom": true
|
|
}
|
|
---*/
|
|
|
|
var thread;
|
|
var res;
|
|
|
|
/*===
|
|
123
|
|
123
|
|
===*/
|
|
|
|
/* Calling via Function.prototype.call() or Function.prototype.apply()
|
|
* currently prevents a yield.
|
|
*/
|
|
|
|
function innerfunc() {
|
|
Duktape.Thread.yield(123);
|
|
}
|
|
|
|
function coroutine1() {
|
|
// This is a native call so the current (naive) handling prevents a later yield
|
|
innerfunc.call();
|
|
}
|
|
|
|
function coroutine2() {
|
|
// Same here
|
|
innerfunc.apply();
|
|
}
|
|
|
|
try {
|
|
thread = new Duktape.Thread(coroutine1);
|
|
res = Duktape.Thread.resume(thread, 0);
|
|
print(res);
|
|
} catch (e) {
|
|
print(e.name);
|
|
}
|
|
|
|
try {
|
|
thread = new Duktape.Thread(coroutine2);
|
|
res = Duktape.Thread.resume(thread, 0);
|
|
print(res);
|
|
} catch (e) {
|
|
print(e.name);
|
|
}
|
|
|