Merge 'Add libsql_wal_get_frame() API' from Pekka Enberg

This pull request implements the `libsql_wal_get_frame()` API. To do
that, we also introduce a `wait_for_completion()` API in I/O dispatcher.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1533
This commit is contained in:
Pekka Enberg
2025-05-27 18:17:32 +03:00
21 changed files with 361 additions and 94 deletions

View File

@@ -462,8 +462,8 @@ impl DatabaseFile {
}
impl limbo_core::DatabaseStorage for DatabaseFile {
fn read_page(&self, page_idx: usize, c: limbo_core::Completion) -> limbo_core::Result<()> {
let r = match c {
fn read_page(&self, page_idx: usize, c: Arc<limbo_core::Completion>) -> limbo_core::Result<()> {
let r = match *c {
limbo_core::Completion::Read(ref r) => r,
_ => unreachable!(),
};
@@ -481,7 +481,7 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
&self,
page_idx: usize,
buffer: Arc<std::cell::RefCell<limbo_core::Buffer>>,
c: limbo_core::Completion,
c: Arc<limbo_core::Completion>,
) -> limbo_core::Result<()> {
let size = buffer.borrow().len();
let pos = (page_idx - 1) * size;
@@ -489,7 +489,7 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
Ok(())
}
fn sync(&self, c: limbo_core::Completion) -> limbo_core::Result<()> {
fn sync(&self, c: Arc<limbo_core::Completion>) -> limbo_core::Result<()> {
self.file.sync(c)
}
}