Skip to content

Commit

Permalink
Simplify BaseProducer::poll to rely on From impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidblewett committed Dec 12, 2024
1 parent dcd606b commit ac574f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ impl<C: ClientContext> Client<C> {
&self.context
}

pub(crate) fn poll_event(
pub(crate) fn poll_event<T: Into<Timeout>>(
&self,
queue: &NativeQueue,
timeout: Timeout,
timeout: T,
) -> EventPollResult<NativeEvent> {
let event = unsafe { NativeEvent::from_ptr(queue.poll(timeout)) };
if let Some(ev) = event {
Expand Down
4 changes: 1 addition & 3 deletions src/producer/base_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,7 @@ where
pub fn poll<T: Into<Timeout>>(&self, timeout: T) {
let deadline: Deadline = timeout.into().into();
loop {
let event = self
.client()
.poll_event(&self.queue, Timeout::After(deadline.remaining()));
let event = self.client().poll_event(&self.queue, &deadline);
if let EventPollResult::Event(ev) = event {
let evtype = unsafe { rdsys::rd_kafka_event_type(ev.ptr()) };
match evtype {
Expand Down

0 comments on commit ac574f2

Please sign in to comment.