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.read(::FIFOBuffer) should block to wait for more data until eof. #121

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

Comments

@samoconnor
Copy link
Contributor

The spec for Base.read(::IO, ::Int) says: "[By default] this function will block repeatedly trying to read all requested bytes, until an error or end-of-file occurs."

For Base.BufferStream and Base.TCPSocket, read() behaves as specified and blocks to wait ffor more data (see JuliaLang/julia#24526).

The current implementation of Base.read(::FIFOBuffer) is just an alias for readavailable:

Base.read(f::FIFOBuffer) = readavailable(f)

readavailable blocks only when the buffer is empty, not until end of file as read should do.

Context of the discovery of this issue: #110

@quinnj
Copy link
Member

quinnj commented Nov 26, 2017

The FIFOBuffer method you reference isn't the same as the docs you referenced from Base. The corresponding Base docs are

read(s::IO, nb=typemax(Int))
Read at most nb bytes from s, returning a Vector{UInt8} of the bytes read.

which I think FIFOBuffer adheres to (though obviously is lacking in details about blocking/non-blocking)

@quinnj quinnj closed this as completed Nov 26, 2017
@samoconnor
Copy link
Contributor Author

Sorry, typo, the doc I referenced is for Base.read(:: IOStream, ::Int).

It seems to me that if FIFOBuffer is intended to be a stream for communicating between tasks, it should follow the pattern set for this by Base. i.e. follow the doc for Base.read(:: IOStream, ::Int) and the behaviour of BufferStream.

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

2 participants