pchickey edited PR #7234:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
pchickey has marked PR #7234 as ready for review.
pchickey requested fitzgen for a review on PR #7234.
pchickey requested wasmtime-core-reviewers for a review on PR #7234.
pchickey requested sunfishcode for a review on PR #7234.
pchickey edited PR #7234:
This PR implements
output-stream.splice
andblocking-splice
.The wit definitions for these functions has been changed to take a
borrow<input-stream>
, rather than the owned resource.Splice performs the equivalent to:
- uses
check-write
to determine how much input is accepted by theoutput-stream
.- uses
read
to read up to that much (or thelen
bound provided by caller) from theinput-stream
- uses
write
to write the read data to theoutput-stream
.By implementing this in the host using the
HostInputStream
andHostOutputStream
traits, the read and write are done in terms ofBytes
representation, so there are zero copies of the underlying data made as part of the splice.A blocking splice waits for both read and write readiness before performing those operations.
The
output-stream.forward
method has been deleted from the wit. We believe that the fusion of anoutput-stream
into aninput-stream
(which gives up ownership of both resources, and happens perpetually in the background) is a worthwhile concept to implement some day, but it raises various questions on how progress and errors can be reported, and whether the background work can outlive the calling component, so rather than open that can of worms now we are going to ask users to implement it with their own event loops usingsplice
for now, and look at adding it again in the future.
pchickey updated PR #7234.
pchickey updated PR #7234.
pchickey requested alexcrichton for a review on PR #7234.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Same as above, this and below may no longer be necessary?
alexcrichton created PR review comment:
no longer necessary I think?
pchickey submitted PR review.
pchickey created PR review comment:
You do need to give up the borrow of output before creating input below, because they are both mut borrows into the table. I changed this to use blocks instead of explicit drops to make it a little more obvious.
pchickey updated PR #7234.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Oh? I would imagine that NLL fixes this because
let _: &mut T = val;
AFAIK does nothing in terms of lifetime inference
pchickey submitted PR review.
pchickey created PR review comment:
oh. yes, you're right. im not sure what error message i was trying to get around by writing it that way, but it isnt necessary. at any rate i like the way its written now.
pchickey merged PR #7234.
Last updated: Nov 22 2024 at 17:03 UTC