From: Brendan Hansen Date: Sun, 15 Oct 2023 15:48:01 +0000 (-0500) Subject: changed: using `stream_poll` in `io.Reader` when `Block_On_Read` is set X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=bb0ab92b6d9993f25b930ff4fdd907c43121ee8b;p=onyx.git changed: using `stream_poll` in `io.Reader` when `Block_On_Read` is set --- diff --git a/core/io/reader.onyx b/core/io/reader.onyx index 239e89cc..503d4972 100644 --- a/core/io/reader.onyx +++ b/core/io/reader.onyx @@ -640,7 +640,8 @@ lines :: (r: &Reader, inplace := false, allocator := context.allocator) => // 'stream_poll' that tests if the next read would block, but that // can happen later. if end > 0 && stream.flags & .Block_On_Read { - return .None; + _, data_available := stream_poll(stream, .Read, 0); + if !data_available do return .None; } err, n := stream_read(stream, buffer[end .. buffer.count]); diff --git a/docs/ideas/platform_layer.md b/docs/ideas/platform_layer.md index f74eeb05..9caf9f33 100644 --- a/docs/ideas/platform_layer.md +++ b/docs/ideas/platform_layer.md @@ -76,6 +76,9 @@ this document will serve as that "header file" - `> 0` on success. Returns number of bytes - `0` on no-input, but not error. - `< 0` on error. +- `__wait_for_input(timeout: i32) -> bool` + - waits for standard input to be readable + - return `true` as the default ### Values @@ -149,3 +152,29 @@ this document will serve as that "header file" - `__tty_set(state: &core.os.TTY_State) -> bool` + +## Networking + +### Types +- `SocketData` + +### Procedures +- `__net_sock_create(af: SocketFamily, type: SocketType, proto: SocketProto) -> Result(SocketData, io.Error)` +- `__net_sock_status(SocketData) -> SocketStatus` +- `__net_sock_opt_flag(SocketData, sockopt: SocketOption, flag: bool) -> bool` +- `__net_sock_opt_time(SocketData, sockopt: SocketOption, time: ? u64) -> bool` +- `__net_sock_opt_size(SocketData, sockopt: SocketOption, size: i64) -> bool` +- `__net_sock_bind(SocketData, addr: &SocketAddress) -> bool` +- `__net_sock_listen(SocketData, backlog: i32) -> bool` +- `__net_sock_accept(SocketData, addr: &SocketAddress) -> Result(i32, io.Error)` +- `__net_sock_connect(SocketData, addr: &SocketAddress) -> io.Error` +- `__net_sock_recv_from(SocketData, buf: [] u8, addr: &SocketAddress) -> Result(i32, io.Error)` +- `__net_sock_send_to(SocketData, buf: [] u8, addr: &SocketAddress) -> Result(i32, io.Error)` +- `__net_sock_recv(SocketData, buf: [] u8) -> Result(i32, io.Error)` +- `__net_sock_send(SocketData, buf: [] u8) -> Result(i32, io.Error)` +- `__net_sock_shutdown(SocketData, how: SocketShutdown) -> io.Error` +- `__net_resolve(host: str, port: u16, out_addrs: [] SocketAddress) -> i32` + + +### Values +