Make some opcodes wait for completion

This commit is contained in:
Pekka Enberg
2023-09-02 13:26:44 +03:00
parent 60376ed3dd
commit ae709f04fe
2 changed files with 11 additions and 4 deletions

View File

@@ -26,6 +26,10 @@ impl Cursor {
}
}
pub fn is_empty(&self) -> bool {
self.page.borrow().is_none()
}
pub fn rewind(&mut self) -> Result<()> {
self.page
.replace(Some(self.pager.read_page(self.root_page)?));
@@ -34,10 +38,6 @@ impl Cursor {
Ok(())
}
pub fn is_empty(&self) -> bool {
self.page.borrow().is_none()
}
pub fn next(&mut self) -> Result<Option<Record>> {
let result = self.record.take();
let next = self.get_next_record()?;
@@ -45,6 +45,11 @@ impl Cursor {
Ok(result)
}
pub fn wait_for_completion(&mut self) -> Result<()> {
// TODO: Wait for pager I/O to complete
Ok(())
}
pub fn record(&self) -> Result<Ref<Option<Record>>> {
Ok(self.record.borrow())
}

View File

@@ -216,6 +216,7 @@ impl Program {
pc_if_empty,
} => {
let cursor = state.cursors.get_mut(cursor_id).unwrap();
cursor.wait_for_completion()?;
if cursor.is_empty() {
state.pc = *pc_if_empty;
} else {
@@ -256,6 +257,7 @@ impl Program {
pc_if_next,
} => {
let cursor = state.cursors.get_mut(cursor_id).unwrap();
cursor.wait_for_completion()?;
if cursor.has_record() {
state.pc = *pc_if_next;
} else {