Skip to content

Peek? #6

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

Closed
sunfishcode opened this issue Mar 26, 2021 · 1 comment
Closed

Peek? #6

sunfishcode opened this issue Mar 26, 2021 · 1 comment

Comments

@sunfishcode
Copy link
Member

Posix's recv function can have a MSG_PEEK flag, which tells it to read data without consuming it, so that subsequent calls to recv read it again. Is this useful to have in I/O Streams?

We can implement this efficiently for some devices, such as sockets (using recv), but not others, such as pipes on POSIX, though we could always emulated it by adding our own buffer.

On the other hand, if we don't have a peek, it would simplify the API, and userspace can always implement its own peek functionality by using its own buffer, though this may be less efficient for devices that already do support peek.

@sunfishcode
Copy link
Member Author

wasi-io is being subsumed by wit streams, though we can also ask whether wit streams should support a peek operation.

The wit stream model is one where the user provides a buffer and registers interest, and then data asynchronously arrives in the buffer. A peek operation would work when the data is being copied in from a second buffer, but in cases where the host manages to write the data straight into the user's buffer, peek would require the host to keep an extra copy of the data.

So for the moment, it doesn't seem like peek will make sense. And going forward, we can certainly re-open this if other considerations emerge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant