Skip to content

Proposal: add output-stream::(blocking-)close #86

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ and stream is ready for writing again.</p>
</ul>
<h4><a name="method_output_stream_subscribe"></a><code>[method]output-stream.subscribe: func</code></h4>
<p>Create a <a href="#pollable"><code>pollable</code></a> which will resolve once the output-stream
is ready for more writing, or an error has occurred. When this
pollable is ready, <code>check-write</code> will return <code>ok(n)</code> with n&gt;0, or an
error.</p>
is ready for more writing, has closed, or an error has occurred.
When this pollable is ready, <code>check-write</code> will return <code>ok(n)</code>
with n&gt;0, or an error.</p>
<p>If the stream is closed, this pollable is always ready immediately.</p>
<p>The created <a href="#pollable"><code>pollable</code></a> is a child resource of the <a href="#output_stream"><code>output-stream</code></a>.
Implementations may trap if the <a href="#output_stream"><code>output-stream</code></a> is dropped before
Expand Down
23 changes: 20 additions & 3 deletions wit/streams.wit
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,27 @@ interface streams {
@since(version = 0.2.0)
blocking-flush: func() -> result<_, stream-error>;

/// Request to flush buffered output and initiate a graceful shutdown
/// afterwards. This function never blocks.
///
/// This behaves similar to `flush` in that after calling this function,
/// the stream will not accept any new writes and `check-write` returns
/// `ok(0)` while the flushing & closing is in progress. Unlike `flush`,
/// the stream never reverts to being writable again. The `subscribe`
/// pollable will become ready when the stream has fully closed.
@unstable(feature = io-output-stream-close)
close: func() -> result<_, stream-error>;

/// Functionally equivalent to calling `close` and then blocking until
/// it actually has been closed. After this method returns, all methods
/// on this stream return `stream-error::closed`.
@unstable(feature = io-output-stream-close)
blocking-close: func() -> result<_, stream-error>;

/// Create a `pollable` which will resolve once the output-stream
/// is ready for more writing, or an error has occurred. When this
/// pollable is ready, `check-write` will return `ok(n)` with n>0, or an
/// error.
/// is ready for more writing, has closed, or an error has occurred.
/// When this pollable is ready, `check-write` will return `ok(n)`
/// with n>0, or an error.
///
/// If the stream is closed, this pollable is always ready immediately.
///
Expand Down