mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat: op registration in core (#3002)
This commit is contained in:
parent
ae26a9c7a2
commit
ffbf0c20cc
8 changed files with 207 additions and 91 deletions
|
@ -58,6 +58,13 @@ SharedQueue Binary Layout
|
|||
Deno.core.recv(handleAsyncMsgFromRust);
|
||||
}
|
||||
|
||||
function ops() {
|
||||
// op id 0 is a special value to retreive the map of registered ops.
|
||||
const opsMapBytes = Deno.core.send(0, new Uint8Array([]), null);
|
||||
const opsMapJson = String.fromCharCode.apply(null, opsMapBytes);
|
||||
return JSON.parse(opsMapJson);
|
||||
}
|
||||
|
||||
function assert(cond) {
|
||||
if (!cond) {
|
||||
throw Error("assert");
|
||||
|
@ -84,7 +91,6 @@ SharedQueue Binary Layout
|
|||
return shared32[INDEX_NUM_RECORDS] - shared32[INDEX_NUM_SHIFTED_OFF];
|
||||
}
|
||||
|
||||
// TODO(ry) rename to setMeta
|
||||
function setMeta(index, end, opId) {
|
||||
shared32[INDEX_OFFSETS + 2 * index] = end;
|
||||
shared32[INDEX_OFFSETS + 2 * index + 1] = opId;
|
||||
|
@ -189,7 +195,8 @@ SharedQueue Binary Layout
|
|||
push,
|
||||
reset,
|
||||
shift
|
||||
}
|
||||
},
|
||||
ops
|
||||
};
|
||||
|
||||
assert(window[GLOBAL_NAMESPACE] != null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue