mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-12 03:34:20 +01:00
Minor improvement in flush api
This commit is contained in:
@@ -975,8 +975,8 @@ pub fn write_pages_vectored(
|
||||
|
||||
// Create the atomic counters
|
||||
let runs_left = Arc::new(AtomicUsize::new(run_count));
|
||||
flush.new_flush();
|
||||
let done = flush.done.clone();
|
||||
done.store(false, Ordering::Release);
|
||||
// we know how many runs, but we don't know how many buffers per run, so we can only give an
|
||||
// estimate of the capacity
|
||||
const EST_BUFF_CAPACITY: usize = 32;
|
||||
|
||||
@@ -393,9 +393,19 @@ impl PendingFlush {
|
||||
done: Arc::new(AtomicBool::new(true)),
|
||||
}
|
||||
}
|
||||
fn clear(&mut self) {
|
||||
pub(super) fn new_flush(&self) {
|
||||
turso_assert!(
|
||||
self.is_done(),
|
||||
"should not reset new flush without being in done state"
|
||||
);
|
||||
self.done.store(false, Ordering::Release);
|
||||
}
|
||||
fn clear(&self) {
|
||||
self.done.store(true, Ordering::Relaxed);
|
||||
}
|
||||
fn is_done(&self) -> bool {
|
||||
self.done.load(Ordering::Acquire)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for OngoingCheckpoint {
|
||||
@@ -1476,12 +1486,7 @@ impl WalFile {
|
||||
self.ongoing_checkpoint.state = CheckpointState::WaitFlush;
|
||||
}
|
||||
CheckpointState::WaitFlush => {
|
||||
if !self
|
||||
.ongoing_checkpoint
|
||||
.pending_flush
|
||||
.done
|
||||
.load(Ordering::Acquire)
|
||||
{
|
||||
if !self.ongoing_checkpoint.pending_flush.is_done() {
|
||||
return Ok(IOResult::IO);
|
||||
}
|
||||
tracing::debug!("finished checkpoint backfilling batch");
|
||||
@@ -1503,10 +1508,7 @@ impl WalFile {
|
||||
// Release all locks and return the current num of wal frames and the amount we backfilled
|
||||
CheckpointState::Done => {
|
||||
turso_assert!(
|
||||
self.ongoing_checkpoint
|
||||
.pending_flush
|
||||
.done
|
||||
.load(Ordering::Relaxed),
|
||||
self.ongoing_checkpoint.pending_flush.is_done(),
|
||||
"checkpoint pending flush must have finished"
|
||||
);
|
||||
let mut checkpoint_result = {
|
||||
|
||||
Reference in New Issue
Block a user