aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorJosh Wolfe <thejoshwolfe@gmail.com>2018-11-18 19:43:13 -0500
committerJosh Wolfe <thejoshwolfe@gmail.com>2018-11-18 19:43:13 -0500
commit3c05ad401282b0eb8b9960a2b521fc1375c4087e (patch)
tree6e537026109d4f5b33a500c8cbfdc54f7fafd31e /std
parentf8a782fb2ec63b89fadb409f7378066a26945d3b (diff)
downloadzig-3c05ad401282b0eb8b9960a2b521fc1375c4087e.tar.gz
zig-3c05ad401282b0eb8b9960a2b521fc1375c4087e.zip
atomic.Int.set
Diffstat (limited to 'std')
-rw-r--r--std/atomic/int.zig4
1 files changed, 4 insertions, 0 deletions
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);
}