mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
std: some more docs for std.atomic.Int
This commit is contained in:
parent
513e8161dd
commit
eb4d93ece3
@ -30,11 +30,13 @@ pub fn Int(comptime T: type) type {
|
|||||||
@atomicStore(T, &self.unprotected_value, value, ordering);
|
@atomicStore(T, &self.unprotected_value, value, ordering);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Twos complement wraparound increment
|
||||||
/// Returns previous value
|
/// Returns previous value
|
||||||
pub fn incr(self: *Self) T {
|
pub fn incr(self: *Self) T {
|
||||||
return self.rmw(.Add, 1, .SeqCst);
|
return self.rmw(.Add, 1, .SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Twos complement wraparound decrement
|
||||||
/// Returns previous value
|
/// Returns previous value
|
||||||
pub fn decr(self: *Self) T {
|
pub fn decr(self: *Self) T {
|
||||||
return self.rmw(.Sub, 1, .SeqCst);
|
return self.rmw(.Sub, 1, .SeqCst);
|
||||||
@ -52,6 +54,8 @@ pub fn Int(comptime T: type) type {
|
|||||||
return self.rmw(.Xchg, new_value, .SeqCst);
|
return self.rmw(.Xchg, new_value, .SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Twos complement wraparound add
|
||||||
|
/// Returns previous value
|
||||||
pub fn fetchAdd(self: *Self, op: T) T {
|
pub fn fetchAdd(self: *Self, op: T) T {
|
||||||
return self.rmw(.Add, op, .SeqCst);
|
return self.rmw(.Add, op, .SeqCst);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user