| ... | @@ -285,13 +285,11 @@ pub const Node = struct { | ... | @@ -285,13 +285,11 @@ pub const Node = struct { |
| 285 | assert(parent == .none or @intFromEnum(parent) < node_storage_buffer_len); | 285 | assert(parent == .none or @intFromEnum(parent) < node_storage_buffer_len); |
| 286 | | 286 | |
| 287 | const storage = storageByIndex(free_index); | 287 | const storage = storageByIndex(free_index); |
| 288 | storage.* = .{ | 288 | @atomicStore(u32, &storage.completed_count, 0, .monotonic); |
| 289 | .completed_count = 0, | 289 | @atomicStore(u32, &storage.estimated_total_count, std.math.lossyCast(u32, estimated_total_items), .monotonic); |
| 290 | .estimated_total_count = std.math.lossyCast(u32, estimated_total_items), | | |
| 291 | .name = [1]u8{0} ** max_name_len, | | |
| 292 | }; | | |
| 293 | const name_len = @min(max_name_len, name.len); | 290 | const name_len = @min(max_name_len, name.len); |
| 294 | @memcpy(storage.name[0..name_len], name[0..name_len]); | 291 | for (storage.name[0..name_len], name[0..name_len]) |*dest, src| @atomicStore(u8, dest, src, .monotonic); |
| | 292 | for (storage.name[name_len..]) |*dest| @atomicStore(u8, dest, 0, .monotonic); |
| 295 | | 293 | |
| 296 | const parent_ptr = parentByIndex(free_index); | 294 | const parent_ptr = parentByIndex(free_index); |
| 297 | assert(parent_ptr.* == .unused); | 295 | assert(parent_ptr.* == .unused); |
| ... | @@ -765,7 +763,7 @@ fn serialize(serialized_buffer: *Serialized.Buffer) Serialized { | ... | @@ -765,7 +763,7 @@ fn serialize(serialized_buffer: *Serialized.Buffer) Serialized { |
| 765 | var begin_parent = @atomicLoad(Node.Parent, parent_ptr, .acquire); | 763 | var begin_parent = @atomicLoad(Node.Parent, parent_ptr, .acquire); |
| 766 | while (begin_parent != .unused) { | 764 | while (begin_parent != .unused) { |
| 767 | const dest_storage = &serialized_buffer.storage[serialized_len]; | 765 | const dest_storage = &serialized_buffer.storage[serialized_len]; |
| 768 | @memcpy(&dest_storage.name, &storage_ptr.name); | 766 | for (&dest_storage.name, &storage_ptr.name) |*dest, *src| dest.* = @atomicLoad(u8, src, .monotonic); |
| 769 | dest_storage.estimated_total_count = @atomicLoad(u32, &storage_ptr.estimated_total_count, .acquire); | 767 | dest_storage.estimated_total_count = @atomicLoad(u32, &storage_ptr.estimated_total_count, .acquire); |
| 770 | dest_storage.completed_count = @atomicLoad(u32, &storage_ptr.completed_count, .monotonic); | 768 | dest_storage.completed_count = @atomicLoad(u32, &storage_ptr.completed_count, .monotonic); |
| 771 | const end_parent = @atomicLoad(Node.Parent, parent_ptr, .acquire); | 769 | const end_parent = @atomicLoad(Node.Parent, parent_ptr, .acquire); |