mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
perf: eager poll async ops in Isolate (#3046)
This commit is contained in:
parent
6056595357
commit
4221b90c3f
8 changed files with 240 additions and 93 deletions
|
@ -75,11 +75,17 @@ export async function sendAsync(
|
|||
const promiseId = nextPromiseId();
|
||||
args = Object.assign(args, { promiseId });
|
||||
const promise = util.createResolvable<Ok>();
|
||||
promiseTable.set(promiseId, promise);
|
||||
|
||||
const argsUi8 = encode(args);
|
||||
const resUi8 = core.dispatch(opId, argsUi8, zeroCopy);
|
||||
util.assert(resUi8 == null);
|
||||
const buf = core.dispatch(opId, argsUi8, zeroCopy);
|
||||
if (buf) {
|
||||
// Sync result.
|
||||
const res = decode(buf);
|
||||
promise.resolve(res);
|
||||
} else {
|
||||
// Async result.
|
||||
promiseTable.set(promiseId, promise);
|
||||
}
|
||||
|
||||
const res = await promise;
|
||||
return unwrapResponse(res);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue