mirror of
https://github.com/ziglang/zig.git
synced 2024-11-28 08:02:32 +00:00
atomic.Int.set
This commit is contained in:
parent
f8a782fb2e
commit
3c05ad4012
@ -26,6 +26,10 @@ pub fn Int(comptime T: type) type {
|
|||||||
return @atomicLoad(T, &self.unprotected_value, AtomicOrder.SeqCst);
|
return @atomicLoad(T, &self.unprotected_value, AtomicOrder.SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set(self: *Self, new_value: T) void {
|
||||||
|
_ = self.xchg(new_value);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn xchg(self: *Self, new_value: T) T {
|
pub fn xchg(self: *Self, new_value: T) T {
|
||||||
return @atomicRmw(T, &self.unprotected_value, builtin.AtomicRmwOp.Xchg, new_value, AtomicOrder.SeqCst);
|
return @atomicRmw(T, &self.unprotected_value, builtin.AtomicRmwOp.Xchg, new_value, AtomicOrder.SeqCst);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user