Skip to content

Commit

Permalink
refactor: remove unnecessary push_flags methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherlock-Holo committed Jul 1, 2024
1 parent 411a609 commit 98868bc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 58 deletions.
31 changes: 0 additions & 31 deletions compio-driver/src/iour/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,37 +238,6 @@ impl Driver {
}
}

pub fn push_flags<T: crate::sys::OpCode + 'static>(
&mut self,
op: &mut Key<T>,
) -> Poll<(io::Result<usize>, u32)> {
instrument!(compio_log::Level::TRACE, "push_flags", ?op);
let user_data = op.user_data();
let op_pin = op.as_op_pin();
trace!("push RawOp");
match op_pin.create_entry() {
OpEntry::Submission(entry) => {
#[allow(clippy::useless_conversion)]
if let Err(err) = self.push_raw(entry.user_data(user_data as _).into()) {
return Poll::Ready((Err(err), 0));
}
Poll::Pending
}
#[cfg(feature = "io-uring-sqe128")]
OpEntry::Submission128(entry) => {
if let Err(err) = self.push_raw(entry.user_data(user_data as _)) {
return Poll::Ready((Err(err), 0));
}
Poll::Pending
}
OpEntry::Blocking => match self.push_blocking(user_data) {
Err(err) => Poll::Ready((Err(err), 0)),
Ok(true) => Poll::Pending,
Ok(false) => Poll::Ready((Err(io::Error::from_raw_os_error(libc::EBUSY)), 0)),
},
}
}

fn push_blocking(&mut self, user_data: usize) -> io::Result<bool> {
let handle = self.handle()?;
let completed = self.pool_completed.clone();
Expand Down
18 changes: 0 additions & 18 deletions compio-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,24 +272,6 @@ impl Proactor {
}
}

/// Push an operation into the driver, and return the unique key, called
/// user-defined data, associated with it.
pub fn push_flags<T: OpCode + 'static>(
&mut self,
op: T,
) -> PushEntry<Key<T>, (BufResult<usize, T>, u32)> {
let mut op = self.driver.create_op(op);
match self.driver.push_flags(&mut op) {
Poll::Pending => PushEntry::Pending(op),
Poll::Ready((res, flags)) => {
op.set_result(res);
op.set_flags(flags);
// SAFETY: just completed.
PushEntry::Ready(unsafe { op.into_inner_flags() })
}
}
}

/// Poll the driver and get completed entries.
/// You need to call [`Proactor::pop`] to get the pushed operations.
pub fn poll(
Expand Down
14 changes: 5 additions & 9 deletions compio-runtime/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,6 @@ impl Runtime {
self.driver.borrow_mut().push(op)
}

fn submit_flags_raw<T: OpCode + 'static>(
&self,
op: T,
) -> PushEntry<Key<T>, (BufResult<usize, T>, u32)> {
self.driver.borrow_mut().push_flags(op)
}

/// Submit an operation to the runtime.
///
/// You only need this when authoring your own [`OpCode`].
Expand All @@ -261,9 +254,12 @@ impl Runtime {
&self,
op: T,
) -> impl Future<Output = (BufResult<usize, T>, u32)> {
match self.submit_flags_raw(op) {
match self.submit_raw(op) {
PushEntry::Pending(user_data) => Either::Left(OpFlagsFuture::new(user_data)),
PushEntry::Ready(res) => Either::Right(ready(res)),
PushEntry::Ready(res) => {
// submit_flags won't be ready immediately
Either::Right(ready((res, 0)))
}
}
}

Expand Down

0 comments on commit 98868bc

Please sign in to comment.