summaryrefslogtreecommitdiff
path: root/core/core.js
diff options
context:
space:
mode:
authorInteon <42113979+inteon@users.noreply.github.com>2021-02-23 13:08:50 +0100
committerGitHub <noreply@github.com>2021-02-23 13:08:50 +0100
commitdccf5e0c5c7f04409809104dd23472bcc058e170 (patch)
tree23bad9b434c45fd08315abef66f1fe16add14a44 /core/core.js
parent2e24af23002b6d77543861bf9b2a6027e0357a93 (diff)
refactor(core): Allow multiple overflown responses in single poll (#9433)
This commit rewrites "JsRuntime::poll" function to fix a corner case that might caused "overflown_response" to be overwritten by other overflown response. The logic has been changed to allow returning multiple overflown response alongside responses from shared queue.
Diffstat (limited to 'core/core.js')
-rw-r--r--core/core.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/core.js b/core/core.js
index a96ce81d7..bda6739a2 100644
--- a/core/core.js
+++ b/core/core.js
@@ -155,12 +155,7 @@ SharedQueue Binary Layout
asyncHandlers[opId] = cb;
}
- function handleAsyncMsgFromRust(opId, buf) {
- if (buf) {
- // This is the overflow_response case of deno::JsRuntime::poll().
- asyncHandlers[opId](buf);
- return;
- }
+ function handleAsyncMsgFromRust() {
while (true) {
const opIdBuf = shift();
if (opIdBuf == null) {
@@ -169,6 +164,10 @@ SharedQueue Binary Layout
assert(asyncHandlers[opIdBuf[0]] != null);
asyncHandlers[opIdBuf[0]](opIdBuf[1]);
}
+
+ for (let i = 0; i < arguments.length; i += 2) {
+ asyncHandlers[arguments[i]](arguments[i + 1]);
+ }
}
function dispatch(opName, control, ...zeroCopy) {