Commit f33395ce6a
Changed files (1)
lib
std
lib/std/Progress.zig
@@ -269,6 +269,19 @@ pub const Node = struct {
storageByIndex(index).setIpcFd(fd);
}
+ /// Posix-only. Thread-safe. Assumes the node is storing an IPC file
+ /// descriptor.
+ pub fn getIpcFd(node: Node) ?posix.fd_t {
+ const index = node.index.unwrap() orelse return null;
+ const storage = storageByIndex(index);
+ const int = @atomicLoad(u32, &storage.completed_count, .monotonic);
+ return switch (@typeInfo(posix.fd_t)) {
+ .Int => @bitCast(int),
+ .Pointer => @ptrFromInt(int),
+ else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
+ };
+ }
+
fn storageByIndex(index: Node.Index) *Node.Storage {
return &global_progress.node_storage[@intFromEnum(index)];
}
@@ -329,6 +342,11 @@ var default_draw_buffer: [4096]u8 = undefined;
var debug_start_trace = std.debug.Trace.init;
+pub const have_ipc = switch (builtin.os.tag) {
+ .wasi, .freestanding, .windows => false,
+ else => true,
+};
+
const noop_impl = builtin.single_threaded or switch (builtin.os.tag) {
.wasi, .freestanding => true,
else => false,