feat: pass cancellation token to interpreter

This commit is contained in:
Jindřich Moravec 2024-02-05 22:13:48 +01:00
parent f5d45f6a1d
commit eeb34a51ce
5 changed files with 45 additions and 13 deletions

View file

@ -1,5 +1,6 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use minisql::cancellation::Cancellation;
pub struct ResetCancelToken {
is_canceled: Arc<AtomicBool>,
@ -12,10 +13,6 @@ impl ResetCancelToken {
}
}
pub fn is_canceled(&self) -> bool {
self.is_canceled.load(Ordering::SeqCst)
}
pub fn cancel(&self) {
self.is_canceled.store(true, Ordering::SeqCst);
}
@ -25,6 +22,12 @@ impl ResetCancelToken {
}
}
impl Cancellation for ResetCancelToken {
fn is_canceled(&self) -> bool {
self.is_canceled.load(Ordering::SeqCst)
}
}
impl Clone for ResetCancelToken {
fn clone(&self) -> Self {
Self {

View file

@ -189,7 +189,6 @@ where
parse_and_validate(query, &db_schema)?
};
// TODO: PASS DOWN RESET CANCEL TOKEN
state.interpret(writer, operation).await?;
state.interpret(writer, token, operation).await?;
Ok(())
}