use std::cell::Cell;
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Work {
pub rows: usize,
pub probes: usize,
}
thread_local! {
static CURRENT: Cell<Option<Work>> = const { Cell::new(None) };
}
pub fn begin() {
CURRENT.set(Some(Work::default()));
}
pub fn take() -> Work {
CURRENT.replace(None).unwrap_or_default()
}
pub(crate) fn row() {
CURRENT.with(|current| {
if let Some(mut work) = current.get() {
work.rows += 1;
current.set(Some(work));
}
});
}
pub(crate) fn probe() {
CURRENT.with(|current| {
if let Some(mut work) = current.get() {
work.probes += 1;
current.set(Some(work));
}
});
}