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
18 changes: 15 additions & 3 deletions src/memory/persona/distill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,21 @@ impl CallBudget {
/// Reserve one call, returning `false` once the budget is spent. Lock-free
/// and correct under the concurrent `buffered` digest stream.
fn try_acquire(&self) -> bool {
self.0
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |n| n.checked_sub(1))
.is_ok()
// CAS loop rather than `fetch_update`/`try_update`: the former is
// deprecated on the newest stable, the latter is not in our MSRV.
let mut current = self.0.load(Ordering::SeqCst);
loop {
let Some(next) = current.checked_sub(1) else {
return false;
};
match self
.0
.compare_exchange_weak(current, next, Ordering::SeqCst, Ordering::SeqCst)
{
Ok(_) => return true,
Err(actual) => current = actual,
}
}
}

/// Calls still available in this run.
Expand Down
Loading