Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Use fetch_max instead #341

Open
recmo opened this issue Sep 24, 2019 · 0 comments
Open

Use fetch_max instead #341

recmo opened this issue Sep 24, 2019 · 0 comments
Assignees
Labels
refactor Improves the code quality tracker Issues generated from source comments

Comments

@recmo
Copy link
Contributor

recmo commented Sep 24, 2019

On 2019-09-24 @recmo wrote in 0ed4308 “Refactor, use Relax”:

Use fetch_max instead
See https://doc.rust-lang.org/std/sync/atomic/struct.AtomicUsize.html#method.fetch_max
This is pending rust-lang/rust#48655

        System.dealloc(ptr, layout);
        let _ = self.allocated.fetch_sub(layout.size(), Relaxed);
    }
}

// TODO: Use `fetch_max` instead
// See https://doc.rust-lang.org/std/sync/atomic/struct.AtomicUsize.html#method.fetch_max
// This is pending https://github.com/rust-lang/rust/issues/48655
fn fetch_max(atom: &AtomicUsize, value: usize) -> usize {
    let mut prev = atom.load(Relaxed);
    while prev < value {
        match atom.compare_exchange_weak(prev, value, Relaxed, Relaxed) {
            Ok(_) => return value,

From utils/logging-allocator/src/logging_allocator.rs:125

@recmo recmo added refactor Improves the code quality tracker Issues generated from source comments labels Sep 24, 2019
@recmo recmo self-assigned this Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
refactor Improves the code quality tracker Issues generated from source comments
Projects
None yet
Development

No branches or pull requests

1 participant