Skip to content
Open
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
8 changes: 4 additions & 4 deletions tinyufo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ impl<T: Clone + Send + Sync + 'static> FiFoQueues<T> {
};
let old = buckets.insert(key, bucket);
if old.is_none() {
// Always push key first before updating weight
// If doing the other order, another concurrent thread might not
// find things to evict
self.small.push(key);
// Always updating weight's before push key
// another concurrent thread might evict it before we add weight's
// risking an usize underflow
self.small_weight.fetch_add(weight as usize, SeqCst);
self.small.push(key);
} // else: two threads are racing adding the item
// TODO: compare old.weight and update accordingly
return evicted;
Expand Down