summaryrefslogtreecommitdiff
path: root/core/examples/http_bench_json_ops.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/examples/http_bench_json_ops.js')
-rw-r--r--core/examples/http_bench_json_ops.js23
1 files changed, 3 insertions, 20 deletions
diff --git a/core/examples/http_bench_json_ops.js b/core/examples/http_bench_json_ops.js
index ad36dd674..12d79a0ce 100644
--- a/core/examples/http_bench_json_ops.js
+++ b/core/examples/http_bench_json_ops.js
@@ -19,28 +19,11 @@ function accept(serverRid) {
return Deno.core.opAsync("accept", serverRid);
}
-/**
- * Reads a packet from the rid, presumably an http request. data is ignored.
- * Returns bytes read.
- */
-function read(rid, data) {
- return Deno.core.opAsync("read", rid, data);
-}
-
-/** Writes a fixed HTTP response to the socket rid. Returns bytes written. */
-function write(rid, data) {
- return Deno.core.opAsync("write", rid, data);
-}
-
-function close(rid) {
- Deno.core.opSync("close", rid);
-}
-
async function serve(rid) {
try {
while (true) {
- await read(rid, requestBuf);
- await write(rid, responseBuf);
+ await Deno.core.read(rid, requestBuf);
+ await Deno.core.write(rid, responseBuf);
}
} catch (e) {
if (
@@ -50,7 +33,7 @@ async function serve(rid) {
throw e;
}
}
- close(rid);
+ Deno.core.close(rid);
}
async function main() {