Skip to content

Commit 675d341

Browse files
fix: free up space for all 3 inner queues
1 parent 17ef68a commit 675d341

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,14 @@ struct Chan<T> {
441441
}
442442

443443
impl<T> Chan<T> {
444+
fn shrink_to_fit(&mut self) {
445+
self.queue.shrink_to_fit();
446+
self.waiting.shrink_to_fit();
447+
if let Some((_, ref mut v)) = self.sending {
448+
v.shrink_to_fit();
449+
}
450+
}
451+
444452
fn pull_pending(&mut self, pull_extra: bool) {
445453
if let Some((cap, sending)) = &mut self.sending {
446454
let effective_cap = *cap + pull_extra as usize;
@@ -699,8 +707,7 @@ impl<T> Shared<T> {
699707
}
700708

701709
fn shrink_to_fit(&self) {
702-
let mut lock = wait_lock(&self.chan);
703-
lock.queue.shrink_to_fit();
710+
wait_lock(&self.chan).shrink_to_fit();
704711
}
705712

706713
fn queue_capacity(&self) -> usize {

0 commit comments

Comments
 (0)