MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_concurrent_reads

Function test_concurrent_reads

atomic-core/src/change/store.rs:982–1006  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

980
981 #[test]
982 fn test_concurrent_reads() {
983 use std::sync::Arc;
984 use std::thread;
985
986 let store = Arc::new(MemoryChangeStore::new());
987 let change = create_test_change("Concurrent", b"shared data");
988 let hash = change.hash().unwrap();
989 store.insert(hash, change);
990
991 let handles: Vec<_> = (0..4)
992 .map(|_| {
993 let store = Arc::clone(&store);
994 thread::spawn(move || {
995 for _ in 0..100 {
996 assert!(store.has_change(&hash));
997 let _ = store.get_change(&hash).unwrap();
998 }
999 })
1000 })
1001 .collect();
1002
1003 for handle in handles {
1004 handle.join().unwrap();
1005 }
1006 }
1007
1008 // ------------------------------------------------------------------------
1009 // Edge Case Tests

Callers

nothing calls this directly

Calls 5

create_test_changeFunction · 0.70
unwrapMethod · 0.45
hashMethod · 0.45
insertMethod · 0.45
get_changeMethod · 0.45

Tested by

no test coverage detected