tur/async_pipe
stdlib/async_pipe.tur
non-blocking stdin/stdout pipe I/O for the cooperative scheduler.
Since: Phase T24
defn
async-read-stdin
(async-read-stdin [buf-size :int])
read up to buf-size bytes from stdin in non-blocking mode.
Parameters
| buf-size | maximum number of bytes to read |
Returns
int -- bytes read (>= 0), 0 on EOF, -1 on error
Example
(async-read-stdin 1024) ; => bytes-read count (0 on EOF)
Since: Phase T24
defn
async-stdin-buf
(async-stdin-buf)
retrieve the buffer pointer from the last async-read-stdin call.
Returns
ptr<void> -- pointer to the read buffer in fiber-local storage (caller must free)
Example
(async-stdin-buf) ; => buf-ptr
Since: Phase T24
defn
async-stdin-len
(async-stdin-len)
retrieve the byte count from the last async-read-stdin call.
Returns
int -- number of bytes read in the most recent async-read-stdin
Example
(async-stdin-len) ; => byte count from last async-read-stdin
Since: Phase T24
defn
async-write-stdout
(async-write-stdout [data :cstr len :int])
write len bytes from data to stdout in non-blocking mode.
Parameters
| data | pointer to the bytes to write | |
| len | number of bytes to write |
Returns
int -- total bytes written, or -1 on error
Example
(async-write-stdout "hello\n" 6) ; => total bytes written (6 here)
Since: Phase T24