mirror of
https://github.com/denoland/deno.git
synced 2025-07-24 05:35:33 +00:00
feat(core): Ops can take several zero copy buffers (#4788)
This commit is contained in:
parent
12d741c2fe
commit
becbb56b19
41 changed files with 322 additions and 215 deletions
|
@ -80,7 +80,7 @@ declare global {
|
|||
dispatch(
|
||||
opId: number,
|
||||
control: Uint8Array,
|
||||
zeroCopy?: ArrayBufferView | null
|
||||
...zeroCopy: ArrayBufferView[]
|
||||
): Uint8Array | null;
|
||||
setAsyncHandler(opId: number, cb: (msg: Uint8Array) => void): void;
|
||||
sharedQueue: {
|
||||
|
@ -99,7 +99,7 @@ declare global {
|
|||
send(
|
||||
opId: number,
|
||||
control: null | ArrayBufferView,
|
||||
data?: ArrayBufferView
|
||||
...data: ArrayBufferView[]
|
||||
): null | Uint8Array;
|
||||
|
||||
setMacrotaskCallback(cb: () => boolean): void;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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] : []));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue