diff options
author | Valentin Anger <syrupthinker@gryphno.de> | 2020-06-01 20:20:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 14:20:47 -0400 |
commit | becbb56b19e96e4dd72b861217a855fba953d290 (patch) | |
tree | d9e99771c537ef87a4a945f0120775c337ef90aa /cli/js/ops | |
parent | 12d741c2fe453625d510313beaa2e1c282784c00 (diff) |
feat(core): Ops can take several zero copy buffers (#4788)
Diffstat (limited to 'cli/js/ops')
-rw-r--r-- | cli/js/ops/dispatch_json.ts | 8 | ||||
-rw-r--r-- | cli/js/ops/fetch.ts | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/cli/js/ops/dispatch_json.ts b/cli/js/ops/dispatch_json.ts index 9ff0f13f5..6292c188a 100644 --- a/cli/js/ops/dispatch_json.ts +++ b/cli/js/ops/dispatch_json.ts @@ -59,12 +59,12 @@ export function asyncMsgFromRust(resUi8: Uint8Array): void { export function sendSync( opName: string, args: object = {}, - zeroCopy?: Uint8Array + ...zeroCopy: Uint8Array[] ): Ok { const opId = OPS_CACHE[opName]; util.log("sendSync", opName, opId); const argsUi8 = encode(args); - const resUi8 = core.dispatch(opId, argsUi8, zeroCopy); + const resUi8 = core.dispatch(opId, argsUi8, ...zeroCopy); util.assert(resUi8 != null); const res = decode(resUi8); @@ -75,7 +75,7 @@ export function sendSync( export async function sendAsync( opName: string, args: object = {}, - zeroCopy?: Uint8Array + ...zeroCopy: Uint8Array[] ): Promise<Ok> { const opId = OPS_CACHE[opName]; util.log("sendAsync", opName, opId); @@ -84,7 +84,7 @@ export async function sendAsync( const promise = util.createResolvable<Ok>(); const argsUi8 = encode(args); - const buf = core.dispatch(opId, argsUi8, zeroCopy); + const buf = core.dispatch(opId, argsUi8, ...zeroCopy); if (buf) { // Sync result. const res = decode(buf); diff --git a/cli/js/ops/fetch.ts b/cli/js/ops/fetch.ts index 09b9ac1ec..290376c86 100644 --- a/cli/js/ops/fetch.ts +++ b/cli/js/ops/fetch.ts @@ -24,5 +24,5 @@ export function fetch( zeroCopy = new Uint8Array(body.buffer, body.byteOffset, body.byteLength); } - return sendAsync("op_fetch", args, zeroCopy); + return sendAsync("op_fetch", args, ...(zeroCopy ? [zeroCopy] : [])); } |