mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 13:14:48 +00:00
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.
This commit is contained in:
parent
ee15b49845
commit
36e8c8dfd7
6 changed files with 77 additions and 54 deletions
10
core/lib.deno_core.d.ts
vendored
10
core/lib.deno_core.d.ts
vendored
|
@ -60,6 +60,16 @@ declare namespace Deno {
|
|||
*/
|
||||
function writeAll(rid: number, buf: Uint8Array): Promise<void>;
|
||||
|
||||
/**
|
||||
* Synchronously read from a (stream) resource that implements readSync().
|
||||
*/
|
||||
function readSync(rid: number, buf: Uint8Array): number;
|
||||
|
||||
/**
|
||||
* Synchronously write to a (stream) resource that implements writeSync().
|
||||
*/
|
||||
function writeSync(rid: number, buf: Uint8Array): number;
|
||||
|
||||
/**
|
||||
* Print a message to stdout or stderr
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue