summaryrefslogtreecommitdiff
path: root/core/01_core.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-11-09 19:26:17 +0100
committerGitHub <noreply@github.com>2021-11-09 19:26:17 +0100
commit375ce63c6390cf7710210ce22f14a2b5a02cbfc3 (patch)
tree85100876e5e0b50514385ae3c7ce08493c82b38b /core/01_core.js
parent1eae6c139ee1dac28df57d67d993792b773fa1ff (diff)
feat(core): streams (#12596)
This allows resources to be "streams" by implementing read/write/shutdown. These streams are implicit since their nature (read/write/duplex) isn't known until called, but we could easily add another method to explicitly tag resources as streams. `op_read/op_write/op_shutdown` are now builtin ops provided by `deno_core` Note: this current implementation is simple & straightforward but it results in an additional alloc per read/write call Closes #12556
Diffstat (limited to 'core/01_core.js')
-rw-r--r--core/01_core.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/01_core.js b/core/01_core.js
index 9d4bab65d..75bfc884f 100644
--- a/core/01_core.js
+++ b/core/01_core.js
@@ -146,6 +146,18 @@
return ObjectFromEntries(opSync("op_resources"));
}
+ function read(rid, buf) {
+ return opAsync("op_read", rid, buf);
+ }
+
+ function write(rid, buf) {
+ return opAsync("op_write", rid, buf);
+ }
+
+ function shutdown(rid) {
+ return opAsync("op_shutdown", rid);
+ }
+
function close(rid) {
opSync("op_close", rid);
}
@@ -191,6 +203,9 @@
ops,
close,
tryClose,
+ read,
+ write,
+ shutdown,
print,
resources,
metrics,