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

Base.eof(::FIFOBuffer) should block to wait for more data. #120

Closed
samoconnor opened this issue Nov 20, 2017 · 2 comments
Closed

Base.eof(::FIFOBuffer) should block to wait for more data. #120

samoconnor opened this issue Nov 20, 2017 · 2 comments
Labels

Comments

@samoconnor
Copy link
Contributor

The spec for Base.eof says "If the stream is not yet exhausted, this function will block to wait for more data if necessary, and then return false.".

The current implementation of Base.eof(::FIFOBuffer) does not block:

Base.eof(f::FIFOBuffer) = f.eof && f.nb == 0

The problem is that stream consumers who do while !eof(io) ... rely on the blocking behaviour to avoid spinning at 100% cpu while waiting for data. e.g.: base/io.jl

function write(to::IO, from::IO)
    while !eof(from)
        write(to, readavailable(from))
    end
end

Context of the discovery of this issue: #110

@KristofferC
Copy link
Contributor

Can be closed?

@samoconnor
Copy link
Contributor Author

This has not been fixed as far as I know.
However, FIFOBuffer is no longer used internally by HTTP.jl

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

2 participants