diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-09-30 20:59:44 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-09-30 14:59:44 -0400 |
commit | ffbf0c20ccc4e70281958f18ed117f40bdd91397 (patch) | |
tree | 602fc442c91186e80a57eca85c5069f4a9be04d3 /core/shared_queue.js | |
parent | ae26a9c7a22bf3311648a93a3171f087490c6e4d (diff) |
feat: op registration in core (#3002)
Diffstat (limited to 'core/shared_queue.js')
-rw-r--r-- | core/shared_queue.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/shared_queue.js b/core/shared_queue.js index 22a64a312..7eeb61255 100644 --- a/core/shared_queue.js +++ b/core/shared_queue.js @@ -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); |