Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -0,0 +1,23 @@
|
||||
module main
|
||||
|
||||
import x.atomics
|
||||
|
||||
fn main() {
|
||||
// Basic atomic load and store operations
|
||||
mut value := i32(0)
|
||||
|
||||
// Atomically store a value
|
||||
atomics.store_i32(&value, 42)
|
||||
|
||||
// Atomically load the value
|
||||
loaded := atomics.load_i32(&value)
|
||||
println('Loaded value: ${loaded}') // Output: 42
|
||||
|
||||
// Atomic add: returns the new value after addition
|
||||
new_value := atomics.add_i32(&value, 10)
|
||||
println('After add: ${new_value}') // Output: 52
|
||||
|
||||
// Atomic swap: returns the old value
|
||||
old := atomics.swap_i32(&value, 100)
|
||||
println('Old value: ${old}, new value: ${atomics.load_i32(&value)}') // Output: 52, 100
|
||||
}
|
||||
Reference in new issue
Block a user