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

Method blocking_write_util

crates/test-programs/src/sockets.rs:50–69  ·  view source on GitHub ↗
(&self, mut bytes: &[u8])

Source from the content-addressed store, hash-verified

48
49impl OutputStream {
50 pub fn blocking_write_util(&self, mut bytes: &[u8]) -> Result<(), StreamError> {
51 let timeout = monotonic_clock::subscribe_duration(TIMEOUT_NS);
52 let pollable = self.subscribe();
53
54 while !bytes.is_empty() {
55 pollable.block_until(&timeout).expect("write timed out");
56
57 let permit = self.check_write()?;
58
59 let len = bytes.len().min(permit as usize);
60 let (chunk, rest) = bytes.split_at(len);
61
62 self.write(chunk)?;
63
64 self.blocking_flush()?;
65
66 bytes = rest;
67 }
68 Ok(())
69 }
70}
71
72impl Network {

Calls 10

OkFunction · 0.85
block_untilMethod · 0.80
subscribeMethod · 0.45
is_emptyMethod · 0.45
expectMethod · 0.45
check_writeMethod · 0.45
minMethod · 0.45
lenMethod · 0.45
writeMethod · 0.45
blocking_flushMethod · 0.45