From 3c05ad401282b0eb8b9960a2b521fc1375c4087e Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Sun, 18 Nov 2018 19:43:13 -0500 Subject: [PATCH] atomic.Int.set --- std/atomic/int.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/std/atomic/int.zig b/std/atomic/int.zig index 38b85873c0..94985b914f 100644 --- a/std/atomic/int.zig +++ b/std/atomic/int.zig @@ -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); }