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

Method blocking_receive

crates/test-programs/src/sockets.rs:250–269  ·  view source on GitHub ↗
(&self, count: Range<u64>)

Source from the content-addressed store, hash-verified

248
249impl IncomingDatagramStream {
250 pub fn blocking_receive(&self, count: Range<u64>) -> Result<Vec<IncomingDatagram>, ErrorCode> {
251 let timeout = monotonic_clock::subscribe_duration(TIMEOUT_NS);
252 let pollable = self.subscribe();
253 let mut datagrams = vec![];
254
255 loop {
256 match self.receive(count.end - datagrams.len() as u64) {
257 Ok(mut chunk) => {
258 datagrams.append(&mut chunk);
259
260 if datagrams.len() >= count.start as usize {
261 return Ok(datagrams);
262 } else {
263 pollable.block_until(&timeout)?;
264 }
265 }
266 Err(err) => return Err(err),
267 }
268 }
269 }
270}
271
272impl IpAddress {

Callers 1

Calls 6

OkFunction · 0.85
block_untilMethod · 0.80
subscribeMethod · 0.45
receiveMethod · 0.45
lenMethod · 0.45
appendMethod · 0.45

Tested by 1