diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-08-21 11:47:57 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2020-08-21 13:11:04 +0200 |
commit | fd83df7cdb983030ba111a1e19ad6c9ef5eb6128 (patch) | |
tree | 26ef2bbf905e14b2405e60cd10ab4a77b66adc00 /core/core.js | |
parent | 679a190fcd04116459436353225cd74a567dbe85 (diff) |
Convert the remaining http_bench ops to json ops (#7143)
Diffstat (limited to 'core/core.js')
-rw-r--r-- | core/core.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/core/core.js b/core/core.js index 099472614..82a812030 100644 --- a/core/core.js +++ b/core/core.js @@ -61,7 +61,7 @@ SharedQueue Binary Layout function ops() { // op id 0 is a special value to retrieve the map of registered ops. - const opsMapBytes = send(0, new Uint8Array([])); + const opsMapBytes = send(0); const opsMapJson = String.fromCharCode.apply(null, opsMapBytes); opsCache = JSON.parse(opsMapJson); return { ...opsCache }; @@ -215,12 +215,12 @@ SharedQueue Binary Layout let nextPromiseId = 1; const promiseTable = {}; - function jsonOpAsync(opName, args) { + function jsonOpAsync(opName, args, ...zeroCopy) { setAsyncHandler(opsCache[opName], jsonOpAsyncHandler); args.promiseId = nextPromiseId++; const argsBuf = encodeJson(args); - dispatch(opName, argsBuf); + dispatch(opName, argsBuf, ...zeroCopy); let resolve, reject; const promise = new Promise((resolve_, reject_) => { resolve = resolve_; @@ -232,14 +232,14 @@ SharedQueue Binary Layout return promise; } - function jsonOpSync(opName, args) { + function jsonOpSync(opName, args, ...zeroCopy) { const argsBuf = encodeJson(args); - const res = dispatch(opName, argsBuf); + const res = dispatch(opName, argsBuf, ...zeroCopy); const r = decodeJson(res); - if (r["ok"]) { - return r["ok"]; + if ("ok" in r) { + return r.ok; } else { - throw r["err"]; + throw r.err; } } |