pub trait Max {
type Type;
// Required method
fn fetch_max(&self, val: Self::Type, order: Ordering) -> Self::Type;
}Expand description
Maximum with the current value.
Required Associated Types§
Required Methods§
Sourcefn fetch_max(&self, val: Self::Type, order: Ordering) -> Self::Type
fn fetch_max(&self, val: Self::Type, order: Ordering) -> Self::Type
Maximum with the current value.
Finds the maximum of the current value and the argument val, and sets the new value to the result.
Returns the previous value.
§Examples
use std::sync::atomic::{AtomicU8, Ordering};
use atomic_traits::{Atomic, fetch};
let foo = AtomicU8::new(23);
assert_eq!(fetch::Max::fetch_max(&foo, 42, Ordering::SeqCst), 23);
assert_eq!(Atomic::load(&foo, Ordering::SeqCst), 42);