Skip to content

Commit

Permalink
fix(iour): wait if thread pool is full
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Oct 31, 2024
1 parent 07411d7 commit fa415f5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions compio-driver/src/iour/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ impl Driver {
}
}

fn poll_entries(&mut self, entries: &mut OutEntries) -> bool {
fn poll_blocking(&mut self, entries: &mut OutEntries) {
// Cheaper than pop.
if !self.pool_completed.is_empty() {
while let Some(entry) = self.pool_completed.pop() {
entries.notify(entry);
}
}
}

fn poll_entries(&mut self, entries: &mut OutEntries) -> bool {
self.poll_blocking(entries);

let mut cqueue = self.inner.completion();
cqueue.sync();
Expand Down Expand Up @@ -240,13 +244,13 @@ impl Driver {
self.push_raw(entry.user_data(user_data as _), entries)?;
Poll::Pending
}
OpEntry::Blocking => {
OpEntry::Blocking => loop {
if self.push_blocking(user_data)? {
Poll::Pending
break Poll::Pending;
} else {
Poll::Ready(Err(io::Error::from_raw_os_error(libc::EBUSY)))
self.poll_blocking(entries);
}
}
},
}
}

Expand Down

0 comments on commit fa415f5

Please sign in to comment.