From 7eec1982311326ebbc97d9ce54ce068e82ef016f Mon Sep 17 00:00:00 2001 From: Dave Bakker Date: Thu, 27 Jun 2024 20:50:08 +0200 Subject: [PATCH] Clarify behavior when dropping an active output-stream --- imports.md | 7 +++++-- wit/streams.wit | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/imports.md b/imports.md index dd0c4f2..1b97b03 100644 --- a/imports.md +++ b/imports.md @@ -133,12 +133,15 @@ use the subscribe function to obtain a po for using wasi:io/poll.

resource output-stream

An output bytestream.

-

output-streams are non-blocking to the extent practical on +

output-streams are non-blocking to the extent practical on underlying platforms. Except where specified otherwise, I/O operations also always return promptly, after the number of bytes that can be written promptly, which could even be zero. To wait for the stream to be ready to accept data, the subscribe function to obtain a pollable which can be -polled for using wasi:io/poll.

+polled for using wasi:io/poll.

+

Dropping an output-stream while there's still an active write in +progress may result in the data being lost. Before dropping the stream, +be sure to fully flush your writes.

Functions

[method]input-stream.read: func

Perform a non-blocking read from the stream.

diff --git a/wit/streams.wit b/wit/streams.wit index a57f204..6b8953e 100644 --- a/wit/streams.wit +++ b/wit/streams.wit @@ -112,6 +112,10 @@ interface streams { /// promptly, which could even be zero. To wait for the stream to be ready to /// accept data, the `subscribe` function to obtain a `pollable` which can be /// polled for using `wasi:io/poll`. + /// + /// Dropping an `output-stream` while there's still an active write in + /// progress may result in the data being lost. Before dropping the stream, + /// be sure to fully flush your writes. @since(version = 0.2.0) resource output-stream { /// Check readiness for writing. This function never blocks.