| ... | @@ -30,11 +30,13 @@ pub fn Int(comptime T: type) type { | ... | @@ -30,11 +30,13 @@ pub fn Int(comptime T: type) type { |
| 30 | @atomicStore(T, &self.unprotected_value, value, ordering); | 30 | @atomicStore(T, &self.unprotected_value, value, ordering); |
| 31 | } | 31 | } |
| 32 | | 32 | |
| | 33 | /// Twos complement wraparound increment |
| 33 | /// Returns previous value | 34 | /// Returns previous value |
| 34 | pub fn incr(self: *Self) T { | 35 | pub fn incr(self: *Self) T { |
| 35 | return self.rmw(.Add, 1, .SeqCst); | 36 | return self.rmw(.Add, 1, .SeqCst); |
| 36 | } | 37 | } |
| 37 | | 38 | |
| | 39 | /// Twos complement wraparound decrement |
| 38 | /// Returns previous value | 40 | /// Returns previous value |
| 39 | pub fn decr(self: *Self) T { | 41 | pub fn decr(self: *Self) T { |
| 40 | return self.rmw(.Sub, 1, .SeqCst); | 42 | return self.rmw(.Sub, 1, .SeqCst); |
| ... | @@ -52,6 +54,8 @@ pub fn Int(comptime T: type) type { | ... | @@ -52,6 +54,8 @@ pub fn Int(comptime T: type) type { |
| 52 | return self.rmw(.Xchg, new_value, .SeqCst); | 54 | return self.rmw(.Xchg, new_value, .SeqCst); |
| 53 | } | 55 | } |
| 54 | | 56 | |
| | 57 | /// Twos complement wraparound add |
| | 58 | /// Returns previous value |
| 55 | pub fn fetchAdd(self: *Self, op: T) T { | 59 | pub fn fetchAdd(self: *Self, op: T) T { |
| 56 | return self.rmw(.Add, op, .SeqCst); | 60 | return self.rmw(.Add, op, .SeqCst); |
| 57 | } | 61 | } |