Skip to content

Commit

Permalink
refactor: rename a channel in Store/sync for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier committed Nov 2, 2024
1 parent 4624745 commit ea0c88b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions nomt/src/store/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ impl Sync {
page_diffs,
);

let (beatree_writeout_wd, meta_wd) =
let (beatree_trigger_fsync_rx, meta_wd) =
spawn_prepare_sync_beatree(&self.tp, &mut value_tx, beatree.clone());

let (bbn_writeout_done, ln_writeout_done) =
spawn_fsync_beatree(&self.tp, &shared.bbn_fd, &shared.ln_fd, beatree_writeout_wd);
let (bbn_writeout_done, ln_writeout_done) = spawn_fsync_beatree(
&self.tp,
&shared.bbn_fd,
&shared.ln_fd,
beatree_trigger_fsync_rx,
);
let bitbox_writeout_done = spawn_wal_writeout(&self.tp, &shared.wal_fd, bitbox_wal_wd);

bbn_writeout_done.recv().unwrap();
Expand Down Expand Up @@ -178,23 +182,23 @@ fn spawn_prepare_sync_beatree(
beatree: beatree::Tree,
) -> (Receiver<()>, Receiver<beatree::SyncData>) {
let batch = mem::take(&mut tx.batch);
let (sync_result_tx, sync_result_rx) = channel::bounded(1);
let (trigger_fsync_tx, trigger_fsync_rx) = channel::bounded(1);
let (meta_result_tx, meta_result_rx) = channel::bounded(1);
let tp = tp.clone();
tp.execute(move || {
beatree.commit(batch);
let meta = beatree.prepare_sync();
let _ = sync_result_tx.send(());
let _ = trigger_fsync_tx.send(());
let _ = meta_result_tx.send(meta);
});
(sync_result_rx, meta_result_rx)
(trigger_fsync_rx, meta_result_rx)
}

fn spawn_fsync_beatree(
tp: &ThreadPool,
bbn_fd: &File,
ln_fd: &File,
beatree_writeout_rx: Receiver<()>,
beatree_trigger_fsync_rx: Receiver<()>,
) -> (Receiver<()>, Receiver<()>) {
let (bbn_result_tx, bbn_result_rx) = channel::bounded(1);
let (ln_result_tx, ln_result_rx) = channel::bounded(1);
Expand All @@ -203,7 +207,7 @@ fn spawn_fsync_beatree(
let ln_fd = ln_fd.try_clone().unwrap();
let tp = tp.clone();
move || {
let () = beatree_writeout_rx.recv().unwrap();
let () = beatree_trigger_fsync_rx.recv().unwrap();
tp.execute(move || {
bbn_fd.sync_all().unwrap();
let _ = bbn_result_tx.send(());
Expand Down

0 comments on commit ea0c88b

Please sign in to comment.