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

Can you use peek to fill the buffer? #392

Open
CLOVIS-AI opened this issue Sep 21, 2024 · 2 comments · Fixed by #395
Open

Can you use peek to fill the buffer? #392

CLOVIS-AI opened this issue Sep 21, 2024 · 2 comments · Fixed by #395
Labels

Comments

@CLOVIS-AI
Copy link

With a given source, if I run source.peek().readInt(), does this guarantee that 4 bytes will be read into the source's buffer?

If so, this should be documented in Source.peek().

@TSampley
Copy link

Do you mean the buffer of the Source returned by peek()? Or the original Source that you are invoking peek() on?

In either case, it seems covered by the documentation at the top of the Source interface. Specifically:

...
 * The buffer is refilled on reads as necessary, but it is also possible to ensure it contains enough data
 * using [require] or [request].
 * [Sink] also allows skipping unneeded prefix of data using [skip] and
 * provides look ahead into incoming data, buffering as much as necessary, using [peek].
...

@fzhinkin
Copy link
Collaborator

@CLOVIS-AI, yes, all the data accessed through the peek source will be available inside source's buffer. If there's not enough data in source's buffer to fulfill an operation on a peek source, new data will be fetched into the original source.

@fzhinkin fzhinkin added the doc label Sep 22, 2024
fzhinkin added a commit that referenced this issue Sep 23, 2024
Explicitly documents thread-safety guarantees, PeelSource behavior and FileSystem support for JS-target.

Closes #392, #393, #394
fzhinkin added a commit that referenced this issue Sep 23, 2024
* Improve documentation

Explicitly document thread-safety guarantees, PeekSource behavior and FileSystem support for JS-target.

Closes #392, #393, #394
@fzhinkin fzhinkin linked a pull request Sep 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants