mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
core: cqe result
Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com>
This commit is contained in:
parent
cfeddeaadf
commit
d088640855
3 changed files with 9 additions and 11 deletions
|
@ -101,7 +101,7 @@ impl IO for LinuxIO {
|
|||
)));
|
||||
}
|
||||
let c = unsafe { Rc::from_raw(cqe.user_data() as *const Completion) };
|
||||
c.complete();
|
||||
c.complete(cqe.result());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ pub trait IO {
|
|||
}
|
||||
|
||||
pub type Complete = dyn Fn(Rc<RefCell<Buffer>>);
|
||||
pub type WriteComplete = dyn Fn(usize);
|
||||
pub type WriteComplete = dyn Fn(i32);
|
||||
|
||||
pub enum Completion {
|
||||
Read(ReadCompletion),
|
||||
|
@ -36,10 +36,10 @@ pub struct ReadCompletion {
|
|||
}
|
||||
|
||||
impl Completion {
|
||||
pub fn complete(&self) {
|
||||
pub fn complete(&self, result: i32) {
|
||||
match self {
|
||||
Completion::Read(r) => r.complete(),
|
||||
Completion::Write(w) => w.complete(234234), // fix
|
||||
Completion::Write(w) => w.complete(result), // fix
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ impl WriteCompletion {
|
|||
pub fn new(complete: Box<WriteComplete>) -> Self {
|
||||
Self { complete }
|
||||
}
|
||||
pub fn complete(&self, bytes_written: usize) {
|
||||
pub fn complete(&self, bytes_written: i32) {
|
||||
(self.complete)(bytes_written);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,10 +174,10 @@ pub fn begin_write_database_header(header: &DatabaseHeader, pager: &Pager) -> Re
|
|||
pager.io.run_once()?;
|
||||
|
||||
let buffer_in_cb = buffer_to_copy.clone();
|
||||
let write_complete = Box::new(move |bytes_written: usize| {
|
||||
let write_complete = Box::new(move |bytes_written: i32| {
|
||||
let buf = buffer_in_cb.clone();
|
||||
let buf_len = std::cell::RefCell::borrow(&buf).len();
|
||||
if bytes_written < buf_len {
|
||||
if bytes_written < buf_len as i32 {
|
||||
log::error!("wrote({bytes_written}) less than expected({buf_len})");
|
||||
}
|
||||
// finish_read_database_header(buf, header).unwrap();
|
||||
|
@ -324,14 +324,12 @@ pub fn begin_write_btree_page(pager: &Pager, page: &Rc<RefCell<Page>>) -> Result
|
|||
let buffer = contents.buffer.clone();
|
||||
let write_complete = {
|
||||
let buf_copy = buffer.clone();
|
||||
Box::new(move |bytes_written: usize| {
|
||||
Box::new(move |bytes_written: i32| {
|
||||
let buf_copy = buf_copy.clone();
|
||||
let buf_len = buf_copy.borrow().len();
|
||||
if bytes_written < buf_len {
|
||||
if bytes_written < buf_len as i32 {
|
||||
log::error!("wrote({bytes_written}) less than expected({buf_len})");
|
||||
}
|
||||
println!("done");
|
||||
// finish_read_database_header(buf, header).unwrap();
|
||||
})
|
||||
};
|
||||
dbg!(buffer.borrow().len());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue