aboutsummaryrefslogtreecommitdiff
path: root/std/atomic/queue.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-05-26 12:06:08 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-05-26 12:06:08 -0400
commit1f96a866769423e363f1c48654c0f51ecf75db58 (patch)
tree504b4913f00bd6a32f097ea6061d5fa211d2c940 /std/atomic/queue.zig
parent284ab109c4b83f7bb9a832f284f706e641b002fd (diff)
parentc029f4bfc47b5d6d825f7ae7a3f224e9e9d6ce0b (diff)
downloadzig-1f96a866769423e363f1c48654c0f51ecf75db58.tar.gz
zig-1f96a866769423e363f1c48654c0f51ecf75db58.zip
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat (limited to 'std/atomic/queue.zig')
-rw-r--r--std/atomic/queue.zig14
1 files changed, 8 insertions, 6 deletions
diff --git a/std/atomic/queue.zig b/std/atomic/queue.zig
index e25c8e6b17..35180da8d1 100644
--- a/std/atomic/queue.zig
+++ b/std/atomic/queue.zig
@@ -16,7 +16,7 @@ pub fn Queue(comptime T: type) type {
data: T,
};
- // TODO: well defined copy elision: https://github.com/zig-lang/zig/issues/287
+ // TODO: well defined copy elision: https://github.com/ziglang/zig/issues/287
pub fn init(self: &Self) void {
self.root.next = null;
self.head = &self.root;
@@ -70,7 +70,7 @@ test "std.atomic.queue" {
var queue: Queue(i32) = undefined;
queue.init();
- var context = Context {
+ var context = Context{
.allocator = a,
.queue = &queue,
.put_sum = 0,
@@ -81,16 +81,18 @@ test "std.atomic.queue" {
var putters: [put_thread_count]&std.os.Thread = undefined;
for (putters) |*t| {
- *t = try std.os.spawnThread(&context, startPuts);
+ t.* = try std.os.spawnThread(&context, startPuts);
}
var getters: [put_thread_count]&std.os.Thread = undefined;
for (getters) |*t| {
- *t = try std.os.spawnThread(&context, startGets);
+ t.* = try std.os.spawnThread(&context, startGets);
}
- for (putters) |t| t.wait();
+ for (putters) |t|
+ t.wait();
_ = @atomicRmw(u8, &context.puts_done, builtin.AtomicRmwOp.Xchg, 1, AtomicOrder.SeqCst);
- for (getters) |t| t.wait();
+ for (getters) |t|
+ t.wait();
std.debug.assert(context.put_sum == context.get_sum);
std.debug.assert(context.get_count == puts_per_thread * put_thread_count);