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

Function atomic_wait_massive_timeout

tests/all/memory.rs:845–878  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

843
844#[test]
845fn atomic_wait_massive_timeout() -> Result<()> {
846 let mut config = Config::new();
847 config.shared_memory(true);
848 let engine = Engine::new(&config)?;
849
850 let memory = SharedMemory::new(&engine, MemoryType::shared(1, 1))?;
851 let result = memory.atomic_wait32(0, 1, Some(Duration::MAX));
852 assert_eq!(result, Ok(WaitResult::Mismatch));
853 let result = memory.atomic_wait64(0, 1, Some(Duration::MAX));
854 assert_eq!(result, Ok(WaitResult::Mismatch));
855
856 let done = Arc::new(AtomicBool::new(false));
857 let t = thread::spawn({
858 let memory = memory.clone();
859 let done = done.clone();
860 move || {
861 while !done.load(SeqCst) {
862 memory.atomic_notify(0, 1).unwrap();
863 memory.atomic_notify(8, 1).unwrap();
864 }
865 }
866 });
867
868 let result = memory.atomic_wait32(0, 0, Some(Duration::MAX));
869 assert_eq!(result, Ok(WaitResult::Ok));
870 let result = memory.atomic_wait64(8, 0, Some(Duration::MAX));
871 assert_eq!(result, Ok(WaitResult::Ok));
872
873 done.store(true, SeqCst);
874
875 t.join().unwrap();
876
877 Ok(())
878}

Callers

nothing calls this directly

Calls 12

spawnFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
shared_memoryMethod · 0.45
atomic_wait32Method · 0.45
atomic_wait64Method · 0.45
cloneMethod · 0.45
loadMethod · 0.45
unwrapMethod · 0.45
atomic_notifyMethod · 0.45
storeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected