Skip to content

Commit

Permalink
Minor changes to acyclic, hoping to break deadlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
pyprogrammer committed Oct 10, 2024
1 parent 422e92c commit ead527f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/channel/receiver/acyclic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ pub(super) trait AcyclicReceiver<T: Clone>: ReceiverCommon<T> {
}

fn dequeue(&mut self, manager: &TimeManager) -> Result<ChannelElement<T>, DequeueError> {
match &self.data().head {
match self.data().head {
Some(PeekResult::Closed) => return Err(DequeueError::Closed),
Some(PeekResult::Something(element)) => {
let cloned = element.clone();
Some(PeekResult::Something(_)) => {
let PeekResult::Something(element) = self.data().head.take().unwrap() else {
unreachable!();
};
self.data().head = None;
self.register_recv(cloned.time.max(manager.tick()));
manager.advance(cloned.time);
return Ok(cloned);
manager.advance(element.time);
self.register_recv(element.time.max(manager.tick()));
return Ok(element);
}
None | Some(PeekResult::Nothing(_)) => {}
}
Expand Down

0 comments on commit ead527f

Please sign in to comment.