use std::fmt::Debug;
use std::hint::spin_loop;
use pi_atom::Atom;
use crate::KVDBTableType;
#[derive(Debug, Clone)]
pub enum CreateTableOptions {
Empty, LogOrdTab(usize, usize, usize), BtreeOrdTab(usize, bool), }
#[derive(Debug, Clone)]
pub enum KVDBEvent<Cid: Debug + Clone + Send + PartialEq + Eq + 'static> {
ReportTrInfo, CommitFailed(Atom, Atom, KVDBTableType, Cid, Cid), ConfirmCommited(Atom, Atom, KVDBTableType, Cid, Cid), }
impl<Cid: Debug + Clone + Send + PartialEq + Eq + 'static> KVDBEvent<Cid> {
pub fn is_report_transaction_info(&self) -> bool {
if let Self::ReportTrInfo = self {
true
} else {
false
}
}
pub fn is_commit_failed(&self) -> bool {
if let Self::CommitFailed(_, _, _, _, _) = self {
true
} else {
false
}
}
pub fn is_confirm_commited(&self) -> bool {
if let Self::ConfirmCommited(_, _, _, _, _) = self {
true
} else {
false
}
}
}
#[inline]
pub(crate) fn spin(mut len: u32) -> u32 {
if len < 1 {
len = 1;
} else if len > 10 {
len = 10;
}
for _ in 0..(1 << len) {
spin_loop()
}
len + 1
}