Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improves the code quality tracker Issues generated from source comments
Projects
None yet
Development

No branches or pull requests

1 participant