Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/sync/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,15 @@ impl<V> SyncVec<V> {
r
}

/// Iterate over the current contents. A fresh snapshot is published first,
/// so all elements written so far are visible.
/// Iterate over the current contents. If dirty has un-published writes, a
/// fresh snapshot is published first; otherwise the current snapshot is
/// reused lock-free to avoid leaking retired Box allocations on every call.
pub fn iter(&self) -> Iter<'_, V> {
let g = self.lock.lock();
self.promote();
drop(g);
if self.amended.load(Ordering::Acquire) {
let g = self.lock.lock();
self.promote();
drop(g);
}
Iter {
inner: self.read.load().iter(),
}
Expand Down
Loading