aboutsummaryrefslogtreecommitdiff
path: root/lib/std/atomic
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-04 22:31:02 -0400
committerGitHub <noreply@github.com>2021-07-04 22:31:02 -0400
commitb7da1b2d45bc42a56eea3a143e4237a0712c4769 (patch)
tree5474938657d5dfd9273562c160ad5f1e3a02b824 /lib/std/atomic
parent5d0dad9acdac854d68e1447b90fd3dbde9ff0b2d (diff)
parentc8f90a7e7e10be62634454bf124bef3c6130a0db (diff)
downloadzig-b7da1b2d45bc42a56eea3a143e4237a0712c4769.tar.gz
zig-b7da1b2d45bc42a56eea3a143e4237a0712c4769.zip
Merge pull request #9175 from kprotty/thread
std.Thread enhancements
Diffstat (limited to 'lib/std/atomic')
-rw-r--r--lib/std/atomic/queue.zig12
-rw-r--r--lib/std/atomic/stack.zig12
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/std/atomic/queue.zig b/lib/std/atomic/queue.zig
index cc5b20488b..cee431951c 100644
--- a/lib/std/atomic/queue.zig
+++ b/lib/std/atomic/queue.zig
@@ -214,20 +214,20 @@ test "std.atomic.Queue" {
} else {
try expect(context.queue.isEmpty());
- var putters: [put_thread_count]*std.Thread = undefined;
+ var putters: [put_thread_count]std.Thread = undefined;
for (putters) |*t| {
- t.* = try std.Thread.spawn(startPuts, &context);
+ t.* = try std.Thread.spawn(.{}, startPuts, .{&context});
}
- var getters: [put_thread_count]*std.Thread = undefined;
+ var getters: [put_thread_count]std.Thread = undefined;
for (getters) |*t| {
- t.* = try std.Thread.spawn(startGets, &context);
+ t.* = try std.Thread.spawn(.{}, startGets, .{&context});
}
for (putters) |t|
- t.wait();
+ t.join();
@atomicStore(bool, &context.puts_done, true, .SeqCst);
for (getters) |t|
- t.wait();
+ t.join();
try expect(context.queue.isEmpty());
}
diff --git a/lib/std/atomic/stack.zig b/lib/std/atomic/stack.zig
index 9472df7347..cfdf40fa60 100644
--- a/lib/std/atomic/stack.zig
+++ b/lib/std/atomic/stack.zig
@@ -121,20 +121,20 @@ test "std.atomic.stack" {
}
}
} else {
- var putters: [put_thread_count]*std.Thread = undefined;
+ var putters: [put_thread_count]std.Thread = undefined;
for (putters) |*t| {
- t.* = try std.Thread.spawn(startPuts, &context);
+ t.* = try std.Thread.spawn(.{}, startPuts, .{&context});
}
- var getters: [put_thread_count]*std.Thread = undefined;
+ var getters: [put_thread_count]std.Thread = undefined;
for (getters) |*t| {
- t.* = try std.Thread.spawn(startGets, &context);
+ t.* = try std.Thread.spawn(.{}, startGets, .{&context});
}
for (putters) |t|
- t.wait();
+ t.join();
@atomicStore(bool, &context.puts_done, true, .SeqCst);
for (getters) |t|
- t.wait();
+ t.join();
}
if (context.put_sum != context.get_sum) {