atomic.Int.set

This commit is contained in:
Josh Wolfe 2018-11-18 19:43:13 -05:00
parent f8a782fb2e
commit 3c05ad4012

View File

@ -26,6 +26,10 @@ pub fn Int(comptime T: type) type {
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 {
return @atomicRmw(T, &self.unprotected_value, builtin.AtomicRmwOp.Xchg, new_value, AtomicOrder.SeqCst);
}