| ... | ... | @@ -80,6 +80,8 @@ pub const Options = struct { |
| 80 | 80 | pub const Node = struct { |
| 81 | 81 | index: OptionalIndex, |
| 82 | 82 | |
| 83 | pub const none: Node = .{ .index = .none }; |
| 84 | |
| 83 | 85 | pub const max_name_len = 40; |
| 84 | 86 | |
| 85 | 87 | const Storage = extern struct { |
| ... | ... | @@ -177,9 +179,9 @@ pub const Node = struct { |
| 177 | 179 | pub fn start(node: Node, name: []const u8, estimated_total_items: usize) Node { |
| 178 | 180 | if (noop_impl) { |
| 179 | 181 | assert(node.index == .none); |
| 180 | | return .{ .index = .none }; |
| 182 | return Node.none; |
| 181 | 183 | } |
| 182 | | const node_index = node.index.unwrap() orelse return .{ .index = .none }; |
| 184 | const node_index = node.index.unwrap() orelse return Node.none; |
| 183 | 185 | const parent = node_index.toParent(); |
| 184 | 186 | |
| 185 | 187 | const freelist_head = &global_progress.node_freelist_first; |
| ... | ... | @@ -196,7 +198,7 @@ pub const Node = struct { |
| 196 | 198 | if (free_index >= global_progress.node_storage.len) { |
| 197 | 199 | // Ran out of node storage memory. Progress for this node will not be tracked. |
| 198 | 200 | _ = @atomicRmw(u32, &global_progress.node_end_index, .Sub, 1, .monotonic); |
| 199 | | return .{ .index = .none }; |
| 201 | return Node.none; |
| 200 | 202 | } |
| 201 | 203 | |
| 202 | 204 | return init(@enumFromInt(free_index), parent, name, estimated_total_items); |
| ... | ... | @@ -357,7 +359,7 @@ pub fn start(options: Options) Node { |
| 357 | 359 | global_progress.initial_delay_ns = options.initial_delay_ns; |
| 358 | 360 | |
| 359 | 361 | if (noop_impl) |
| 360 | | return .{ .index = .none }; |
| 362 | return Node.none; |
| 361 | 363 | |
| 362 | 364 | if (std.process.parseEnvVarInt("ZIG_PROGRESS", u31, 10)) |ipc_fd| { |
| 363 | 365 | global_progress.update_thread = std.Thread.spawn(.{}, ipcThreadRun, .{ |
| ... | ... | @@ -368,12 +370,12 @@ pub fn start(options: Options) Node { |
| 368 | 370 | }), |
| 369 | 371 | }) catch |err| { |
| 370 | 372 | std.log.warn("failed to spawn IPC thread for communicating progress to parent: {s}", .{@errorName(err)}); |
| 371 | | return .{ .index = .none }; |
| 373 | return Node.none; |
| 372 | 374 | }; |
| 373 | 375 | } else |env_err| switch (env_err) { |
| 374 | 376 | error.EnvironmentVariableNotFound => { |
| 375 | 377 | if (options.disable_printing) { |
| 376 | | return .{ .index = .none }; |
| 378 | return Node.none; |
| 377 | 379 | } |
| 378 | 380 | const stderr = std.io.getStdErr(); |
| 379 | 381 | global_progress.terminal = stderr; |
| ... | ... | @@ -386,7 +388,7 @@ pub fn start(options: Options) Node { |
| 386 | 388 | } |
| 387 | 389 | |
| 388 | 390 | if (global_progress.terminal_mode == .off) { |
| 389 | | return .{ .index = .none }; |
| 391 | return Node.none; |
| 390 | 392 | } |
| 391 | 393 | |
| 392 | 394 | if (have_sigwinch) { |
| ... | ... | @@ -408,12 +410,12 @@ pub fn start(options: Options) Node { |
| 408 | 410 | global_progress.update_thread = thread; |
| 409 | 411 | } else |err| { |
| 410 | 412 | std.log.warn("unable to spawn thread for printing progress to terminal: {s}", .{@errorName(err)}); |
| 411 | | return .{ .index = .none }; |
| 413 | return Node.none; |
| 412 | 414 | } |
| 413 | 415 | }, |
| 414 | 416 | else => |e| { |
| 415 | 417 | std.log.warn("invalid ZIG_PROGRESS file descriptor integer: {s}", .{@errorName(e)}); |
| 416 | | return .{ .index = .none }; |
| 418 | return Node.none; |
| 417 | 419 | }, |
| 418 | 420 | } |
| 419 | 421 | |