mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 04:31:04 +00:00
Update std.js
This commit is contained in:
parent
a12c9e740c
commit
1ef71e54bf
15
lib/std.js
15
lib/std.js
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user