Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sockets and other handles to be conditionally driven by an I/O notifier. #9

Open
lithdew opened this issue Nov 19, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@lithdew
Copy link
Owner

lithdew commented Nov 19, 2020

This is just an idea so far, though the idea is that for each exposed syscall (e.g. read()), there would be two variants: Socket.read(buf: []u8) !usize, and Socket.readAsync(buf: []u8) callconv(.Async) !usize.

Another method would be exposed, which is Socket.wait(.{ .read = ?, .write = ? }) callconv(.Async) void which allows users to manually await until a read/write-readiness notification is provided by an I/O notifier for a given file handle.

Calling Socket.read(...) will return immediately if the syscall cannot immediately be completed, and thus may be driven by Socket.wait(.{ .read = true }). Calling Socket.readAsync(...) will automatically retry the syscall, which is done by awaiting for readiness notifications from an I/O notifier via Socket.wait(.{ .read = true }).

Exposing these two variants also allows for Socket's in pike to be used in blocking mode (e.g. read() / write() may be called directly, blocking the current thread until said read() / write() is completed).

@lithdew lithdew added the enhancement New feature or request label Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant