[Pkg-mozext-commits] [adblock-plus] 04/98: Issue 3993 - Implement Utils.yield() in a better way
David Prévot
taffit at moszumanska.debian.org
Tue Oct 24 01:30:12 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 29fb0ea131f04ca2629948983f7008b437601a06
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Apr 26 20:49:10 2016 +0200
Issue 3993 - Implement Utils.yield() in a better way
---
dependencies | 2 +-
lib/io.js | 11 +++++++----
lib/utils.js | 3 +--
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dependencies b/dependencies
index 25b5979..7a6339c 100644
--- a/dependencies
+++ b/dependencies
@@ -1,5 +1,5 @@
_root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/
_self = buildtools/ensure_dependencies.py
buildtools = buildtools hg:3816c08c0f98 git:93e54d4
-adblockpluscore = adblockpluscore hg:d576e2dac412 git:8c6e1bd
+adblockpluscore = adblockpluscore hg:3f1bdb2a4fd4 git:e929b89
adblockplusui = adblockplusui hg:eaf7a04285fa git:d6484f7
diff --git a/lib/io.js b/lib/io.js
index d4392cb..fa9c022 100644
--- a/lib/io.js
+++ b/lib/io.js
@@ -78,7 +78,7 @@ let IO = exports.IO =
let loaded = false;
let error = null;
- let onProgress = function(data)
+ let onProgress = function*(data)
{
let index = (processing ? -1 : Math.max(data.lastIndexOf("\n"), data.lastIndexOf("\r")));
if (index >= 0)
@@ -94,14 +94,14 @@ let IO = exports.IO =
lines.pop();
lines[0] = oldBuffer + lines[0];
for (let i = 0; i < lines.length; i++)
- listener.process(lines[i]);
+ yield listener.process(lines[i]);
}
finally
{
processing = false;
data = buffer;
buffer = "";
- onProgress(data);
+ yield* onProgress(data);
if (loaded)
{
@@ -130,6 +130,9 @@ let IO = exports.IO =
return;
}
+ // We are ignoring return value of listener.process() here because
+ // turning this callback into a generator would be complicated, and
+ // delaying isn't really necessary for the last two calls.
if (buffer !== "")
listener.process(buffer);
listener.process(null);
@@ -179,7 +182,7 @@ let IO = exports.IO =
break;
let data = decoder.decode(array, {stream: true});
- onProgress(data);
+ yield* onProgress(data);
}
yield f.close();
}.bind(this)).then(onSuccess, onError);
diff --git a/lib/utils.js b/lib/utils.js
index 3c9071a..7673cad 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -357,8 +357,7 @@ let Utils = exports.Utils =
this.yield = function() {};
return;
}
- let thread = Services.tm.currentThread;
- while (thread.processNextEvent(false));
+ return new Promise((resolve, reject) => Utils.runAsync(resolve));
},
/**
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list