mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-07 09:14:26 +01:00
Add cancel and drain methods to IO trait
This commit is contained in:
@@ -50,9 +50,6 @@ pub trait File: Send + Sync {
|
||||
})
|
||||
};
|
||||
if let Err(e) = self.pwrite(pos, buf.clone(), child_c) {
|
||||
// best-effort: mark as abort so caller won't wait forever
|
||||
// TODO: when we have `pwrite` and other I/O methods return CompletionError
|
||||
// instead of LimboError, store the error inside
|
||||
c.abort();
|
||||
return Err(e);
|
||||
}
|
||||
@@ -91,6 +88,15 @@ pub trait IO: Clock + Send + Sync {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cancel(&self, c: &[Completion]) -> Result<()> {
|
||||
c.iter().for_each(|c| c.abort());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn drain(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn wait_for_completion(&self, c: Completion) -> Result<()> {
|
||||
while !c.finished() {
|
||||
self.run_once()?
|
||||
|
||||
Reference in New Issue
Block a user