| ... | @@ -269,6 +269,19 @@ pub const Node = struct { | ... | @@ -269,6 +269,19 @@ pub const Node = struct { |
| 269 | storageByIndex(index).setIpcFd(fd); | 269 | storageByIndex(index).setIpcFd(fd); |
| 270 | } | 270 | } |
| 271 | | 271 | |
| | 272 | /// Posix-only. Thread-safe. Assumes the node is storing an IPC file |
| | 273 | /// descriptor. |
| | 274 | pub fn getIpcFd(node: Node) ?posix.fd_t { |
| | 275 | const index = node.index.unwrap() orelse return null; |
| | 276 | const storage = storageByIndex(index); |
| | 277 | const int = @atomicLoad(u32, &storage.completed_count, .monotonic); |
| | 278 | return switch (@typeInfo(posix.fd_t)) { |
| | 279 | .Int => @bitCast(int), |
| | 280 | .Pointer => @ptrFromInt(int), |
| | 281 | else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), |
| | 282 | }; |
| | 283 | } |
| | 284 | |
| 272 | fn storageByIndex(index: Node.Index) *Node.Storage { | 285 | fn storageByIndex(index: Node.Index) *Node.Storage { |
| 273 | return &global_progress.node_storage[@intFromEnum(index)]; | 286 | return &global_progress.node_storage[@intFromEnum(index)]; |
| 274 | } | 287 | } |
| ... | @@ -329,6 +342,11 @@ var default_draw_buffer: [4096]u8 = undefined; | ... | @@ -329,6 +342,11 @@ var default_draw_buffer: [4096]u8 = undefined; |
| 329 | | 342 | |
| 330 | var debug_start_trace = std.debug.Trace.init; | 343 | var debug_start_trace = std.debug.Trace.init; |
| 331 | | 344 | |
| | 345 | pub const have_ipc = switch (builtin.os.tag) { |
| | 346 | .wasi, .freestanding, .windows => false, |
| | 347 | else => true, |
| | 348 | }; |
| | 349 | |
| 332 | const noop_impl = builtin.single_threaded or switch (builtin.os.tag) { | 350 | const noop_impl = builtin.single_threaded or switch (builtin.os.tag) { |
| 333 | .wasi, .freestanding => true, | 351 | .wasi, .freestanding => true, |
| 334 | else => false, | 352 | else => false, |