| ... | ... | @@ -24,7 +24,7 @@ time_report_update_times: []i64, |
| 24 | 24 | |
| 25 | 25 | build_status: std.atomic.Value(abi.BuildStatus), |
| 26 | 26 | /// When an event occurs which means WebSocket clients should be sent updates, call `notifyUpdate` |
| 27 | | /// to increment this value. Each client thread waits for this increment with `std.Thread.Futex`, so |
| 27 | /// to increment this value. Each client thread waits for this increment with `Io.futexWaitTimeout`, so |
| 28 | 28 | /// `notifyUpdate` will wake those threads. Updates are sent on a short interval regardless, so it |
| 29 | 29 | /// is recommended to only use `notifyUpdate` for changes which the user should see immediately. For |
| 30 | 30 | /// instance, we do not call `notifyUpdate` when the number of "unique runs" in the fuzzer changes, |
| ... | ... | @@ -46,7 +46,7 @@ pub const base_clock: Io.Clock = .awake; |
| 46 | 46 | /// Thread-safe. Triggers updates to be sent to connected WebSocket clients; see `update_id`. |
| 47 | 47 | pub fn notifyUpdate(ws: *WebServer) void { |
| 48 | 48 | _ = ws.update_id.rmw(.Add, 1, .release); |
| 49 | | std.Thread.Futex.wake(&ws.update_id, 16); |
| 49 | ws.graph.io.futexWake(u32, &ws.update_id.raw, 16); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | pub const Options = struct { |
| ... | ... | @@ -377,7 +377,18 @@ fn serveWebSocket(ws: *WebServer, sock: *http.Server.WebSocket) !noreturn { |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | prev_time = start_time; |
| 380 | | std.Thread.Futex.timedWait(&ws.update_id, start_update_id, std.time.ns_per_ms * default_update_interval_ms) catch {}; |
| 380 | |
| 381 | const old_cp = io.swapCancelProtection(.blocked); |
| 382 | defer _ = io.swapCancelProtection(old_cp); |
| 383 | io.futexWaitTimeout( |
| 384 | u32, |
| 385 | &ws.update_id.raw, |
| 386 | start_update_id, |
| 387 | .{ .duration = .{ |
| 388 | .clock = .awake, |
| 389 | .raw = .fromMilliseconds(default_update_interval_ms), |
| 390 | } }, |
| 391 | ) catch |err| switch (err) { error.Canceled => unreachable }; |
| 381 | 392 | } |
| 382 | 393 | } |
| 383 | 394 | fn recvWebSocketMessages(ws: *WebServer, sock: *http.Server.WebSocket) void { |