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

Function atomic_wait_timeout_length

tests/all/wait_notify.rs:8–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7#[test]
8fn atomic_wait_timeout_length() -> Result<()> {
9 let sleep_nanoseconds = 500000000;
10 let wat = format!(
11 r#"(module
12 (import "env" "memory" (memory 1 1 shared))
13
14 (func (export "func1") (result i32)
15 (memory.atomic.wait32 (i32.const 0) (i32.const 0) (i64.const {sleep_nanoseconds}))
16 )
17
18 (data (i32.const 0) "\00\00\00\00")
19 )"#
20 );
21 let Some(engine) = engine() else {
22 return Ok(());
23 };
24 let module = Module::new(&engine, wat)?;
25 let mut store = Store::new(&engine, ());
26 let shared_memory = SharedMemory::new(&engine, MemoryType::shared(1, 1))?;
27 let instance = Instance::new(&mut store, &module, &[shared_memory.clone().into()])?;
28 let now = Instant::now();
29 let func_ret = instance
30 .get_typed_func::<(), i32>(&mut store, "func1")
31 .unwrap()
32 .call(&mut store, ())
33 .unwrap();
34 let duration = now.elapsed();
35 assert!(
36 duration.as_nanos() >= sleep_nanoseconds,
37 "duration: {duration:?} < {sleep_nanoseconds:?}"
38 );
39 assert_eq!(func_ret, 2);
40 Ok(())
41}
42
43#[test]
44fn atomic_wait_notify_basic() -> Result<()> {

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
engineFunction · 0.70
newFunction · 0.50
cloneMethod · 0.45
unwrapMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected