Skip to content

Commit

Permalink
Successfully gotten rid of the unwanted Arcs! #30
Browse files Browse the repository at this point in the history
  • Loading branch information
JackKelly committed Jan 30, 2024
1 parent 3187cb4 commit eb4afc3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/io_uring_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ 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!
// TODO: `ObjectStore::get` returns a pinned `Box`, not a pinned `Arc`!
// If we _have_ to replace `Arc` with `Box` then maybe we could share a raw pointer
// with the io_uring thread, and return the Box. But then rustc can't
// guarantee that our Future will still exist. So, at the very least,
// we'd have to use some unsafe code to check if the pointer is null.
pub fn get(&mut self, location: &Path) -> Pin<Arc<dyn Future<Output = Result<Bytes>>>> {
let operation = Operation::Get { location: location.clone() };
let op_future = Arc::pin(OperationFuture::new(operation));
pub async fn get(&mut self, location: &Path) -> Result<Bytes> {
let operation = Operation::Get {
location: location.clone(),
};
let op_future = OperationFuture::new(operation);
self.worker_thread
.sender
.send(op_future.clone())
.send(op_future.shared_state.clone())
.expect("Failed to send message to worker thread!");
op_future
op_future.await
}
}

0 comments on commit eb4afc3

Please sign in to comment.