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

make eof part of stream interface #25

Open
ssfrr opened this issue Nov 23, 2017 · 0 comments
Open

make eof part of stream interface #25

ssfrr opened this issue Nov 23, 2017 · 0 comments
Labels

Comments

@ssfrr
Copy link
Collaborator

ssfrr commented Nov 23, 2017

Currently we signal the end of the stream by returning less data than the user requested. (it will block the task until all the data is available or we hit EOF). Julia IO streams support the eof method, which I think simplifies the logic working with streams somewhat.

current approach:

buf = SampleBuf(Float32, CHUNK_FRAMES, 2)

while true
    n = read!(stream, buf, CHUNK_FRAMES)
    # process `n` frames from buf
    n == CHUNK_FRAMES || break
end

vs.

buf = SampleBuf(Float32, CHUNK_FRAMES, 2)

while !eof(stream)
    n = read!(stream, buf, CHUNK_FRAMES)
    # process `n` frames from buf
end

It would be pretty easy to add eof, the question is whether we modify the stream semantics to allow a short read when we're not at the end of the stream, and only rely on eof. My current feeling is that's a cleaner design, I'm mostly hesitant about the churn.

@ssfrr ssfrr added the design label Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant