Update std.js

This commit is contained in:
Namhyeon Go 2022-05-09 17:55:47 +09:00 committed by GitHub
parent a12c9e740c
commit 1ef71e54bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -342,15 +342,23 @@ function AsyncFunction(f) {
this.f = f;
this.run = function() {
AsyncFunction.counter++; // increase number of async functions
var _this = this;
var f = function() {
_this.f();
AsyncFunction.counter--; // decrease number of async functions
};
if (this.proxyWindow != null) {
try {
this.proxyWindow.setTimeout(1, this.f);
this.proxyWindow.setTimeout(1, f);
} catch (e) {
console.warn("AsyncFunction proxyWindow.setTimeout failed:", e.message);
sleep(1, this.f);
sleep(1, f);
}
} else {
sleep(1, this.f);
sleep(1, f);
}
};
@ -368,6 +376,7 @@ function AsyncFunction(f) {
}
}
};
AsyncFunction.counter = 0; // static variable
global.GetResource = GetResource;
global.sleep = sleep;