summaryrefslogtreecommitdiff
path: root/core/examples/http_bench.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-08-20 09:45:59 -0400
committerGitHub <noreply@github.com>2020-08-20 09:45:59 -0400
commit0095611af98d3039e30ff44444ab83f65bcec554 (patch)
tree2c87ec9c7fc39f5a0af83c179b7f14493a8b6b95 /core/examples/http_bench.js
parentbe1e7ab5320c0a110998818c3916c79b39710613 (diff)
First pass at json ops in core (#7033)
Adds Deno.core.jsonOpSync and Deno.core.jsonOpAsync
Diffstat (limited to 'core/examples/http_bench.js')
-rw-r--r--core/examples/http_bench.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/examples/http_bench.js b/core/examples/http_bench.js
index eba9bb677..ac97e0d88 100644
--- a/core/examples/http_bench.js
+++ b/core/examples/http_bench.js
@@ -80,12 +80,14 @@ function handleAsyncMsgFromRust(buf) {
/** Listens on 0.0.0.0:4500, returns rid. */
function listen() {
- return sendSync(ops["listen"], -1);
+ const { rid } = Deno.core.jsonOpSync("listen", {});
+ return rid;
}
/** Accepts a connection, returns rid. */
-function accept(rid) {
- return sendAsync(ops["accept"], rid);
+async function accept(serverRid) {
+ const { rid } = await Deno.core.jsonOpAsync("accept", { rid: serverRid });
+ return rid;
}
/**
@@ -124,9 +126,8 @@ let ops;
async function main() {
ops = Deno.core.ops();
- for (const opName in ops) {
- Deno.core.setAsyncHandler(ops[opName], handleAsyncMsgFromRust);
- }
+ Deno.core.setAsyncHandler(ops["read"], handleAsyncMsgFromRust);
+ Deno.core.setAsyncHandler(ops["write"], handleAsyncMsgFromRust);
Deno.core.print("http_bench.js start\n");