MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / blocking_close_output

Method blocking_close_output

crates/test-programs/src/tls.rs:28–47  ·  view source on GitHub ↗
(
        &self,
        output: &OutputStream,
    )

Source from the content-addressed store, hash-verified

26
27impl ClientConnection {
28 pub fn blocking_close_output(
29 &self,
30 output: &OutputStream,
31 ) -> Result<(), crate::wasi::io::error::Error> {
32 let timeout = monotonic_clock::subscribe_duration(TIMEOUT_NS);
33 let pollable = output.subscribe();
34
35 self.close_output();
36
37 loop {
38 match output.check_write() {
39 Ok(0) => pollable.block_until(&timeout).expect("timed out"),
40 Ok(_) => unreachable!(
41 "After calling close_output, the output stream should never accept new writes again."
42 ),
43 Err(StreamError::Closed) => return Ok(()),
44 Err(StreamError::LastOperationFailed(e)) => return Err(e),
45 }
46 }
47 }
48}

Callers 1

Calls 6

OkFunction · 0.85
close_outputMethod · 0.80
block_untilMethod · 0.80
subscribeMethod · 0.45
check_writeMethod · 0.45
expectMethod · 0.45

Tested by 1