-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Document and export alloc_request(), notify_filled(). #4484
Conversation
cc: @dcjones (I have a pull request for Zlib.jl in the works). |
cc: @vtjnash, @loladiro |
I'm in favor. I don't think there is currently a way for a C function to write directly to a IOBuffer, and not doing so is pretty inefficient. |
This mechanism is already used by libuv for exactly that purpose, so this is really just to expose that interface. |
This seems fine, the only thing I might suggest is to have
|
What do you mean by "over filled"? What additional field is needed exactly? |
assert that nbytes filled <= size allocated -- additional field is the nbytes allocated. |
Thanks for the feedback, @vtjnash. I've updated the pull request. Let me know if there are any more suggestions, and if not, I'll squash and merge. |
(Assuming this is okay before 0.2, although I don't think it should be controversial.) |
* add alloc_req field to IOBuffer, indicating the size of a reqest * disable writing while a request is in progress
Bump. I squashed the commits. Is there any objection to merging this? |
Bump. |
This is actually part of #3887, which is a good thing, but I'd rather not implement that design haphazardly piece-by-piece. Unfortunately Another way to look at this is to observe that Zlib.jl is doing its own buffering. It appears to be reusing |
First, if there's going to be something better, then I'm perfectly fine with the decision not to merge this. I have generally found the IOBuffer implementation a little awkward, since to use it effectively seems to require deep coupling with other code. That said, I'm not quite following your response, so I wanted to clarify a couple of things, and then get clarification.
As I understand it,
I'm not following you here. For Zlib.jl, at least, my understanding is that it couples zlib with an For efficiency, zlib updates the Beyond reading arrays, what fancier things do you envision the interface being able to do, or what hasn't been implemented yet to pass on to the IOBuffer that would be easier to simply do directly within Zlib.jl? |
Many fancier features have been proposed: automatic byte-swapping, mark/unmark for re-reading buffered data, etc. My proposal is that "user" code (i.e. nearly all code that does I/O) only interact with |
Okay, that sounds good to me! |
These are currently used by libuv to get a pointer to a block of memory to fill, and then update the IOBuffer info.
Zlib.jl currently uses IOBuffers in a similar manner, but copies the data twice. It would be nice if it could use this mechanism, and an exported interface is less likely to break/change than a non-exported one.
Also slightly updated the call signature of notify_filled() to be more friendly to external users, minimally affecting libuv use.