use std::cell::{Cell, RefCell};
use std::thread::LocalKey;
use crate::metrics::ClauseMetricsRecord;
mod aggregate;
mod catalog_show;
mod frontier;
mod graphs;
mod readers;
mod run;
mod write;
pub(crate) struct ClauseRecords(pub(crate) RefCell<Vec<ClauseMetricsRecord>>);
impl crate::metrics::PlanMetricsSink for ClauseRecords {
fn record_clause(&self, record: ClauseMetricsRecord) {
self.0.borrow_mut().push(record);
}
fn record_statement_memos(&self, _record: crate::metrics::StatementMemoRecord) {}
}
pub(crate) use aggregate::*;
pub(crate) use catalog_show::*;
pub(crate) use frontier::*;
pub(crate) use graphs::*;
pub(crate) use readers::*;
pub(crate) use run::*;
pub(crate) use write::*;
pub(crate) fn with_override<V: Copy + 'static, T>(
slot: &'static LocalKey<Cell<Option<V>>>,
value: V,
f: impl FnOnce() -> T,
) -> T {
struct Restore<V: Copy + 'static>(&'static LocalKey<Cell<Option<V>>>, Option<V>);
impl<V: Copy + 'static> Drop for Restore<V> {
fn drop(&mut self) {
self.0.with(|c| c.set(self.1));
}
}
let _restore = Restore(slot, slot.with(|c| c.replace(Some(value))));
f()
}