change JavaScriptEngine to LoopBasedJavaScriptEngine

Everything works like Node.js. loop() will not need be called explicitly any more.
Including some changes:
* Every thread of script has a looper.
* Use a servant thread in gestures functions of GlobalActionAutomator and image available listener of ScreenCapture.
* For keeping events key and touch listener alive, add Loopers.waitWhenIdle to control whether or not Looper should quit when it has nothing to do
This commit is contained in:
hyb1996
2017-07-29 17:46:23 +08:00
parent 11b87d9a51
commit 12037ba488
21 changed files with 382 additions and 173 deletions

View File

@@ -1,4 +1,6 @@
__runtime__.init();
if(__engine_name__ == "rhino"){
__importClass__ = importClass;
var importClass = function(pack){

View File

@@ -2,7 +2,11 @@
module.exports = function(__runtime__, scope){
var timers = Object.create(__runtime__.timers);
scope.__asGlobal__(timers, ['loop', 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate']);
scope.__asGlobal__(timers, ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate']);
scope.loop = function(){
console.warn("loop() has been deprecated and has no effect. Remove it from your code.");
}
return timers;
}