Skip to content

Commit

Permalink
fix: Consider case of full and closed receiver
Browse files Browse the repository at this point in the history
Handle case where the receiver heap first gets full, and all receivers
are dropped, in which case all senders will be notified about the
changed state, but they need to handle the case that no additional
capacity is available.
  • Loading branch information
mantono committed Jan 11, 2024
1 parent ef664ec commit e56cc5e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ where
let (guard, timed_out) = self.shared.senders.wait_timeout(guard, duration).unwrap();
if timed_out.timed_out() {
return Err(SendError::Full(item));
} else if self.shared.is_closed() {
return Err(SendError::Closed(item));
} else if guard.is_full() {
return Err(SendError::Full(item));
}
guard
};
Expand Down

0 comments on commit e56cc5e

Please sign in to comment.