Commit e86a1df9f2

Hadron67 <604700341@qq.com>
2021-04-18 09:47:27
std.atomic: load should take const pointer to Self
1 parent dfb34c3
Changed files (2)
lib
std
lib/std/atomic/bool.zig
@@ -28,7 +28,7 @@ pub const Bool = extern struct {
         return @atomicRmw(bool, &self.unprotected_value, .Xchg, operand, ordering);
     }
 
-    pub fn load(self: *Self, comptime ordering: std.builtin.AtomicOrder) bool {
+    pub fn load(self: *const Self, comptime ordering: std.builtin.AtomicOrder) bool {
         switch (ordering) {
             .Unordered, .Monotonic, .Acquire, .SeqCst => {},
             else => @compileError("Invalid ordering '" ++ @tagName(ordering) ++ "' for a load operation"),
lib/std/atomic/int.zig
@@ -31,7 +31,7 @@ pub fn Int(comptime T: type) type {
             return @atomicRmw(T, &self.unprotected_value, op, operand, ordering);
         }
 
-        pub fn load(self: *Self, comptime ordering: builtin.AtomicOrder) T {
+        pub fn load(self: *const Self, comptime ordering: builtin.AtomicOrder) T {
             switch (ordering) {
                 .Unordered, .Monotonic, .Acquire, .SeqCst => {},
                 else => @compileError("Invalid ordering '" ++ @tagName(ordering) ++ "' for a load operation"),
@@ -59,7 +59,7 @@ pub fn Int(comptime T: type) type {
             return self.rmw(.Sub, 1, .SeqCst);
         }
 
-        pub fn get(self: *Self) T {
+        pub fn get(self: *const Self) T {
             return self.load(.SeqCst);
         }