use polars_core::prelude::DataFrame;
use super::memory_manager::mm;
#[derive(Clone, Copy)]
pub(crate) struct SlotId {
pub(crate) index: u32,
pub(crate) generation: u32,
}
#[derive(Debug, Eq, PartialEq, Hash)]
pub struct Token {
index: u32,
generation: u32,
}
const _: () = assert!(size_of::<Token>() == 8);
impl Drop for Token {
fn drop(&mut self) {
mm().drop_token(self);
}
}
impl Token {
#[inline]
pub(crate) fn new(index: u32, generation: u32) -> Self {
Self { index, generation }
}
#[inline]
pub(crate) fn id(&self) -> SlotId {
SlotId {
index: self.index,
generation: self.generation,
}
}
pub fn height(&self) -> usize {
mm().height(self)
}
pub fn pin(&self) -> &Self {
mm().pin(self);
self
}
pub fn unpin(&self) -> &Self {
mm().unpin(self);
self
}
pub async fn df(&self) -> DataFrame {
mm().df(self).await
}
pub async fn into_df(self) -> DataFrame {
mm().take_df(self).await
}
}