mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 20:14:21 +01:00
Make some opcodes wait for completion
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user