本文簡要介紹rust語言中 std::sync::atomic::AtomicU32.store 的用法。
用法
pub fn store(&self, val: u32, order: Ordering)將值存儲到原子整數中。
store 采用 Ordering 參數,該參數說明了此操作的內存順序。可能的值為 SeqCst 、 Release 和 Relaxed 。
Panics
如果 order 是 Acquire 或 AcqRel 則會出現Panics。
例子
use std::sync::atomic::{AtomicU32, Ordering};
let some_var = AtomicU32::new(5);
some_var.store(10, Ordering::Relaxed);
assert_eq!(some_var.load(Ordering::Relaxed), 10);相關用法
- Rust AtomicU32.swap用法及代碼示例
- Rust AtomicU32.fetch_min用法及代碼示例
- Rust AtomicU32.fetch_max用法及代碼示例
- Rust AtomicU32.into_inner用法及代碼示例
- Rust AtomicU32.fetch_or用法及代碼示例
- Rust AtomicU32.compare_exchange_weak用法及代碼示例
- Rust AtomicU32.compare_and_swap用法及代碼示例
- Rust AtomicU32.fetch_sub用法及代碼示例
- Rust AtomicU32.fetch_update用法及代碼示例
- Rust AtomicU32.load用法及代碼示例
- Rust AtomicU32.fetch_and用法及代碼示例
- Rust AtomicU32.from_mut用法及代碼示例
- Rust AtomicU32.fetch_nand用法及代碼示例
- Rust AtomicU32.fetch_add用法及代碼示例
- Rust AtomicU32.get_mut用法及代碼示例
- Rust AtomicU32.new用法及代碼示例
- Rust AtomicU32.fetch_xor用法及代碼示例
- Rust AtomicU32.as_mut_ptr用法及代碼示例
- Rust AtomicU32.compare_exchange用法及代碼示例
- Rust AtomicU8.fetch_sub用法及代碼示例
- Rust AtomicU8.fetch_or用法及代碼示例
- Rust AtomicUsize.load用法及代碼示例
- Rust AtomicU16.into_inner用法及代碼示例
- Rust AtomicU16.from_mut用法及代碼示例
- Rust AtomicU8.as_mut_ptr用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 std::sync::atomic::AtomicU32.store。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
