How to do timedWait on the new synchronization primitives (e.g. Io.Semaphore)?

I need my threads to regularly wake up during wait periods to e.g. send a regular keep-alive signal to the server, or to timeout a network request initiated by another thread.
How would I do this with the new interface? I really don’t want to resort to a busy-wait or sleeping.

2 Likes

Would you mind opening an issue for this? I just confirmed indeed std.Thread.Semaphore and std.Thread.Condition each had a timedWait, and the new Io.Condition and Io.Semaphore should have a timedWait as well.

3 Likes

I have this PR open for a while

https://codeberg.org/ziglang/zig/pulls/31278

1 Like

Done: https://codeberg.org/ziglang/zig/issues/31912

Sorry that slipped under the radar for me, I wasn’t ignoring it intentionally