diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-05-26 12:06:08 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-05-26 12:06:08 -0400 |
| commit | 1f96a866769423e363f1c48654c0f51ecf75db58 (patch) | |
| tree | 504b4913f00bd6a32f097ea6061d5fa211d2c940 /std/atomic/stack.zig | |
| parent | 284ab109c4b83f7bb9a832f284f706e641b002fd (diff) | |
| parent | c029f4bfc47b5d6d825f7ae7a3f224e9e9d6ce0b (diff) | |
| download | zig-1f96a866769423e363f1c48654c0f51ecf75db58.tar.gz zig-1f96a866769423e363f1c48654c0f51ecf75db58.zip | |
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat (limited to 'std/atomic/stack.zig')
| -rw-r--r-- | std/atomic/stack.zig | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/std/atomic/stack.zig b/std/atomic/stack.zig index 4a3dbef32b..400a1a3c4f 100644 --- a/std/atomic/stack.zig +++ b/std/atomic/stack.zig @@ -14,9 +14,7 @@ pub fn Stack(comptime T: type) type { }; pub fn init() Self { - return Self { - .root = null, - }; + return Self{ .root = null }; } /// push operation, but only if you are the first item in the stack. if you did not succeed in @@ -75,7 +73,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, @@ -86,16 +84,18 @@ test "std.atomic.stack" { 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); |
