aboutsummaryrefslogtreecommitdiff
path: root/std/atomic
diff options
context:
space:
mode:
Diffstat (limited to 'std/atomic')
-rw-r--r--std/atomic/int.zig4
-rw-r--r--std/atomic/queue.zig20
-rw-r--r--std/atomic/stack.zig12
3 files changed, 18 insertions, 18 deletions
diff --git a/std/atomic/int.zig b/std/atomic/int.zig
index 38b85873c0..0d6f358503 100644
--- a/std/atomic/int.zig
+++ b/std/atomic/int.zig
@@ -3,13 +3,13 @@ const AtomicOrder = builtin.AtomicOrder;
/// Thread-safe, lock-free integer
pub fn Int(comptime T: type) type {
- return struct {
+ return struct.{
unprotected_value: T,
pub const Self = @This();
pub fn init(init_val: T) Self {
- return Self{ .unprotected_value = init_val };
+ return Self.{ .unprotected_value = init_val };
}
/// Returns previous value
diff --git a/std/atomic/queue.zig b/std/atomic/queue.zig
index e1cadf5d1c..c0c050f0ba 100644
--- a/std/atomic/queue.zig
+++ b/std/atomic/queue.zig
@@ -7,7 +7,7 @@ const assert = std.debug.assert;
/// Many producer, many consumer, non-allocating, thread-safe.
/// Uses a mutex to protect access.
pub fn Queue(comptime T: type) type {
- return struct {
+ return struct.{
head: ?*Node,
tail: ?*Node,
mutex: std.Mutex,
@@ -16,7 +16,7 @@ pub fn Queue(comptime T: type) type {
pub const Node = std.LinkedList(T).Node;
pub fn init() Self {
- return Self{
+ return Self.{
.head = null,
.tail = null,
.mutex = std.Mutex.init(),
@@ -126,7 +126,7 @@ pub fn Queue(comptime T: type) type {
};
}
-const Context = struct {
+const Context = struct.{
allocator: *std.mem.Allocator,
queue: *Queue(i32),
put_sum: isize,
@@ -154,7 +154,7 @@ test "std.atomic.Queue" {
var a = &fixed_buffer_allocator.allocator;
var queue = Queue(i32).init();
- var context = Context{
+ var context = Context.{
.allocator = a,
.queue = &queue,
.put_sum = 0,
@@ -198,7 +198,7 @@ fn startPuts(ctx: *Context) u8 {
while (put_count != 0) : (put_count -= 1) {
std.os.time.sleep(1); // let the os scheduler be our fuzz
const x = @bitCast(i32, r.random.scalar(u32));
- const node = ctx.allocator.create(Queue(i32).Node{
+ const node = ctx.allocator.create(Queue(i32).Node.{
.prev = undefined,
.next = undefined,
.data = x,
@@ -226,14 +226,14 @@ fn startGets(ctx: *Context) u8 {
test "std.atomic.Queue single-threaded" {
var queue = Queue(i32).init();
- var node_0 = Queue(i32).Node{
+ var node_0 = Queue(i32).Node.{
.data = 0,
.next = undefined,
.prev = undefined,
};
queue.put(&node_0);
- var node_1 = Queue(i32).Node{
+ var node_1 = Queue(i32).Node.{
.data = 1,
.next = undefined,
.prev = undefined,
@@ -242,14 +242,14 @@ test "std.atomic.Queue single-threaded" {
assert(queue.get().?.data == 0);
- var node_2 = Queue(i32).Node{
+ var node_2 = Queue(i32).Node.{
.data = 2,
.next = undefined,
.prev = undefined,
};
queue.put(&node_2);
- var node_3 = Queue(i32).Node{
+ var node_3 = Queue(i32).Node.{
.data = 3,
.next = undefined,
.prev = undefined,
@@ -260,7 +260,7 @@ test "std.atomic.Queue single-threaded" {
assert(queue.get().?.data == 2);
- var node_4 = Queue(i32).Node{
+ var node_4 = Queue(i32).Node.{
.data = 4,
.next = undefined,
.prev = undefined,
diff --git a/std/atomic/stack.zig b/std/atomic/stack.zig
index b69a93733c..9222b8de50 100644
--- a/std/atomic/stack.zig
+++ b/std/atomic/stack.zig
@@ -5,19 +5,19 @@ const AtomicOrder = builtin.AtomicOrder;
/// Many reader, many writer, non-allocating, thread-safe
/// Uses a spinlock to protect push() and pop()
pub fn Stack(comptime T: type) type {
- return struct {
+ return struct.{
root: ?*Node,
lock: u8,
pub const Self = @This();
- pub const Node = struct {
+ pub const Node = struct.{
next: ?*Node,
data: T,
};
pub fn init() Self {
- return Self{
+ return Self.{
.root = null,
.lock = 0,
};
@@ -54,7 +54,7 @@ pub fn Stack(comptime T: type) type {
}
const std = @import("../index.zig");
-const Context = struct {
+const Context = struct.{
allocator: *std.mem.Allocator,
stack: *Stack(i32),
put_sum: isize,
@@ -81,7 +81,7 @@ test "std.atomic.stack" {
var a = &fixed_buffer_allocator.allocator;
var stack = Stack(i32).init();
- var context = Context{
+ var context = Context.{
.allocator = a,
.stack = &stack,
.put_sum = 0,
@@ -125,7 +125,7 @@ fn startPuts(ctx: *Context) u8 {
while (put_count != 0) : (put_count -= 1) {
std.os.time.sleep(1); // let the os scheduler be our fuzz
const x = @bitCast(i32, r.random.scalar(u32));
- const node = ctx.allocator.create(Stack(i32).Node{
+ const node = ctx.allocator.create(Stack(i32).Node.{
.next = undefined,
.data = x,
}) catch unreachable;