Skip to content

Commit

Permalink
Making good progress with having an io_uring thread. #30
Browse files Browse the repository at this point in the history
  • Loading branch information
JackKelly committed Jan 30, 2024
1 parent d8af3e9 commit acf7624
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/io_uring_local.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use bytes::Bytes;
use object_store::{path::Path, Result};
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use url::Url;

use crate::io_uring_thread::WorkerThread;
use crate::operation_future::{Operation, OperationFuture};

#[derive(Debug)]
pub struct IoUringLocal {
config: Arc<Config>,
worker_thread: WorkerThread,
}

// We can't re-use `object_store::local::Config` because it's private.
Expand All @@ -29,10 +35,15 @@ impl Default for IoUringLocal {
impl IoUringLocal {
/// Create new filesystem storage with no prefix
pub fn new() -> Self {
// TODO: Set up thread and Sender!
Self {
config: Arc::new(Config {
root: Url::parse("file:///").unwrap(),
}),
worker_thread: WorkerThread {
handle: todo!(),
sender: todo!(),
},
}
}
}
Expand All @@ -42,7 +53,17 @@ impl IoUringLocal {
// use the exact same function signatures as `ObjectStore`).
impl IoUringLocal {
// TODO: `IoUringLocal` shouldn't implement `get` because `ObjectStore::get` has a default impl.
// Instead, `IoUringLocal` should impl `get_opts` which returns a `Result<GetResult>`.
// But I'm keeping things simple for now!
pub async fn get(&mut self, location: &Path) -> Result<Bytes> {}
// Instead, `IoUringLocal` should impl `get_opts` which returns a `Result<GetResult>`.
// But I'm keeping things simple for now!
// TODO: `ObjectStore::get` returns a pinned `Box`, not a pinned `Arc`!
pub fn get(&mut self, location: &Path) -> Pin<Arc<dyn Future<Output = Arc<Result<Bytes>>>>> {
let location = location.clone();
let operation = Operation::Get { location };
let op_future = Arc::pin(OperationFuture::new(operation));
self.worker_thread
.sender
.send(op_future.clone())
.expect("Failed to send message to worker thread!");
op_future
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
mod io_uring_local;
mod io_uring_thread;
mod operation_future;

0 comments on commit acf7624

Please sign in to comment.