Skip to content

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

@samoconnor

Description

@samoconnor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions