Skip to content

Commit c186cd1

Browse files
committedMay 3, 2018
std.atomic - use AtomicOrder.SeqCst for everything
also use less memory for the tests
·
0.15.20.3.0
1 parent 6f002e7 commit c186cd1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎std/atomic/queue.zig‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ pub fn Queue(comptime T: type) type {
3131
}
3232

3333
pub fn get(self: &Self) ?&Node {
34-
var head = @atomicLoad(&Node, &self.head, AtomicOrder.Acquire);
34+
var head = @atomicLoad(&Node, &self.head, AtomicOrder.SeqCst);
3535
while (true) {
3636
const node = head.next ?? return null;
37-
head = @cmpxchgWeak(&Node, &self.head, head, node, AtomicOrder.Release, AtomicOrder.Acquire) ?? return node;
37+
head = @cmpxchgWeak(&Node, &self.head, head, node, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? return node;
3838
}
3939
}
4040
};
@@ -56,7 +56,7 @@ test "std.atomic.queue" {
5656
var direct_allocator = std.heap.DirectAllocator.init();
5757
defer direct_allocator.deinit();
5858

59-
var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 64 * 1024 * 1024);
59+
var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 600 * 1024);
6060
defer direct_allocator.allocator.free(plenty_of_memory);
6161

6262
var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);

‎std/atomic/stack.zig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn Stack(comptime T: type) type {
3535
}
3636

3737
pub fn pop(self: &Self) ?&Node {
38-
var root = @atomicLoad(?&Node, &self.root, AtomicOrder.Acquire);
38+
var root = @atomicLoad(?&Node, &self.root, AtomicOrder.SeqCst);
3939
while (true) {
4040
root = @cmpxchgWeak(?&Node, &self.root, root, (root ?? return null).next, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? return root;
4141
}
@@ -63,7 +63,7 @@ test "std.atomic.stack" {
6363
var direct_allocator = std.heap.DirectAllocator.init();
6464
defer direct_allocator.deinit();
6565

66-
var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 64 * 1024 * 1024);
66+
var plenty_of_memory = try direct_allocator.allocator.alloc(u8, 600 * 1024);
6767
defer direct_allocator.allocator.free(plenty_of_memory);
6868

6969
var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory);

0 commit comments

Comments
 (0)
Please sign in to comment.