Skip to content

Commit

Permalink
chore: verify concurrent write batches
Browse files Browse the repository at this point in the history
  • Loading branch information
Hao Hao committed Jul 28, 2023
1 parent 8dbb079 commit d0d23f1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions firewood/examples/rev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ fn main() {
.expect("db initiation should succeed");
let items = vec![("dof", "verb"), ("doe", "reindeer"), ("dog", "puppy")];

std::thread::scope(|scope| {
scope.spawn(|| {
db.new_writebatch()
.kv_insert("k1", "v1".into())
.unwrap()
.commit();
});

scope.spawn(|| {
db.new_writebatch()
.kv_insert("k2", "v2".into())
.unwrap()
.commit();
});
});

assert_eq!("v1".as_bytes().to_vec(), db.kv_get("k1").unwrap());
assert_eq!("v2".as_bytes().to_vec(), db.kv_get("k2").unwrap());

let mut revision_tracker = RevisionTracker::new(db);

revision_tracker.create_revisions(items.into_iter());
Expand Down

0 comments on commit d0d23f1

Please sign in to comment.