From 36e8c8dfd759458aa735f79f5cc7cd346c727914 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 6 Apr 2023 00:14:16 +0200 Subject: feat(core): sync io ops in core (#18603) This commit adds op_read_sync and op_write_sync to core. These ops are similar to op_read and op_write, but they are synchronous. Just like the async ops, they operate on generic `deno_core::Resource` objects. These now have new `read_byob_sync` and `write_sync` methods, with default implementations throwing "NotSupported" errors, just like the async counterparts. There are no `write_all` or `read` equivalents, because the optimizations they unlock are not useful in synchronous contexts. --- core/01_core.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/01_core.js') diff --git a/core/01_core.js b/core/01_core.js index c46c30070..ab54316e5 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -412,6 +412,8 @@ readAll: opAsync.bind(null, "op_read_all"), write: opAsync.bind(null, "op_write"), writeAll: opAsync.bind(null, "op_write_all"), + readSync: (rid, buffer) => ops.op_read_sync(rid, buffer), + writeSync: (rid, buffer) => ops.op_write_sync(rid, buffer), shutdown: opAsync.bind(null, "op_shutdown"), print: (msg, isErr) => ops.op_print(msg, isErr), setMacrotaskCallback: (fn) => ops.op_set_macrotask_callback(fn), -- cgit v1.2.3