From eb4d93ece3f9fb218a644e32823fb0052fe22653 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 19 Nov 2020 00:44:38 +1100 Subject: [PATCH] std: some more docs for std.atomic.Int --- lib/std/atomic/int.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/std/atomic/int.zig b/lib/std/atomic/int.zig index 45e176a472..7811ed71c7 100644 --- a/lib/std/atomic/int.zig +++ b/lib/std/atomic/int.zig @@ -30,11 +30,13 @@ pub fn Int(comptime T: type) type { @atomicStore(T, &self.unprotected_value, value, ordering); } + /// Twos complement wraparound increment /// Returns previous value pub fn incr(self: *Self) T { return self.rmw(.Add, 1, .SeqCst); } + /// Twos complement wraparound decrement /// Returns previous value pub fn decr(self: *Self) T { return self.rmw(.Sub, 1, .SeqCst); @@ -52,6 +54,8 @@ pub fn Int(comptime T: type) type { return self.rmw(.Xchg, new_value, .SeqCst); } + /// Twos complement wraparound add + /// Returns previous value pub fn fetchAdd(self: *Self, op: T) T { return self.rmw(.Add, op, .SeqCst); }