}
writeln!(writer)?;
if SHUTTING_DOWN.load(atomic::Ordering::Relaxed) {
break;
}
}
writer.flush()?;
Ok(())
}
pub(crate) fn is_unrecoverably_reorged(&self) -> bool {
self.unrecoverably_reorged.load(atomic::Ordering::Relaxed)
}
fn begin_read(&self) -> Result<rtx::Rtx> {
Ok(rtx::Rtx(self.database.begin_read()?))
}
fn begin_write(&self) -> Result<WriteTransaction> {
let mut tx = self.database.begin_write()?;
tx.set_durability(self.durability);
Ok(tx)
}
fn increment_statistic(wtx: &WriteTransaction, statistic: Statistic, n: u64) -> Result {
let mut statistic_to_count = wtx.open_table(STATISTIC_TO_COUNT)?;
let value = statistic_to_count
.get(&(statistic.key()))?
.map(|x| x.value())
.unwrap_or(0)
+ n;
statistic_to_count.insert(&statistic.key(), &value)?;
Ok(())
}
#[cfg(test)]
pub(crate) fn statistic(&self, statistic: Statistic) -> u64 {
self
.database
.begin_read()
.unwrap()