Skip to content

Commit 9cc2d10

Browse files
committed
Fix concurrent pop test
1 parent f62ab32 commit 9cc2d10

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/test_tree.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ fn test_varied_compression_ratios() {
9090
#[test]
9191
#[cfg(not(miri))] // can't create threads
9292
fn concurrent_tree_pops() -> sled::Result<()> {
93-
use std::convert::TryInto;
9493
use std::thread;
9594

9695
let db = sled::open("db")?;
@@ -100,13 +99,18 @@ fn concurrent_tree_pops() -> sled::Result<()> {
10099
db.insert(x.to_be_bytes(), &[])?;
101100
}
102101

102+
let mut threads = vec![];
103+
103104
// Pop 5 values using multiple threads
104105
for _ in 0..5 {
105106
let db = db.clone();
106-
thread::spawn(move || {
107-
let (key, _) = db.pop_min().unwrap().unwrap();
108-
let x = u32::from_be_bytes((&*key).try_into().unwrap());
109-
});
107+
threads.push(thread::spawn(move || {
108+
db.pop_min().unwrap().unwrap();
109+
}));
110+
}
111+
112+
for thread in threads.into_iter() {
113+
thread.join().unwrap();
110114
}
111115

112116
assert!(

0 commit comments

Comments
 (0)