Trait mmtk::util::metadata::metadata_val_traits::MetadataValue
source · pub trait MetadataValue: Unsigned + Zero + WrappingAdd + WrappingSub + Bits + BitwiseOps + ToPrimitive + Copy + FromPrimitive + Display + Debug {
// Required methods
unsafe fn load(addr: Address) -> Self;
unsafe fn load_atomic(addr: Address, order: Ordering) -> Self;
unsafe fn store(addr: Address, value: Self);
unsafe fn store_atomic(addr: Address, value: Self, order: Ordering);
unsafe fn compare_exchange(
addr: Address,
current: Self,
new: Self,
success: Ordering,
failure: Ordering
) -> Result<Self, Self>;
unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self;
unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self;
unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self;
unsafe fn fetch_or(addr: Address, value: Self, order: Ordering) -> Self;
unsafe fn fetch_update<F>(
addr: Address,
set_order: Ordering,
fetch_order: Ordering,
f: F
) -> Result<Self, Self>
where F: FnMut(Self) -> Option<Self>;
}
Expand description
The number type for accessing metadata. It requires a few traits from num-traits and a few traits we defined above. The methods in this trait are mostly about atomically accessing such types.
Required Methods§
sourceunsafe fn load(addr: Address) -> Self
unsafe fn load(addr: Address) -> Self
Non atomic load
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type. The caller also needs to be aware that the method is not thread safe, as it is a non-atomic operation.
sourceunsafe fn load_atomic(addr: Address, order: Ordering) -> Self
unsafe fn load_atomic(addr: Address, order: Ordering) -> Self
Atomic load
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.
sourceunsafe fn store(addr: Address, value: Self)
unsafe fn store(addr: Address, value: Self)
Non atomic store
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type. The caller also needs to be aware that the method is not thread safe, as it is a non-atomic operation.
sourceunsafe fn store_atomic(addr: Address, value: Self, order: Ordering)
unsafe fn store_atomic(addr: Address, value: Self, order: Ordering)
Atomic store
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type. The caller also needs to be aware that the method is not thread safe, as it is a non-atomic operation.
sourceunsafe fn compare_exchange(
addr: Address,
current: Self,
new: Self,
success: Ordering,
failure: Ordering
) -> Result<Self, Self>
unsafe fn compare_exchange( addr: Address, current: Self, new: Self, success: Ordering, failure: Ordering ) -> Result<Self, Self>
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.
sourceunsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self
unsafe fn fetch_add(addr: Address, value: Self, order: Ordering) -> Self
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.
sourceunsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self
unsafe fn fetch_sub(addr: Address, value: Self, order: Ordering) -> Self
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.
sourceunsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self
unsafe fn fetch_and(addr: Address, value: Self, order: Ordering) -> Self
§Safety
The caller needs to guarantee that the address is valid, and can be used as a pointer to the type.