mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-08 14:54:42 +00:00
* std: add Thread.Condition.timedWait I needed the equivalent of `std::condition_variable::wait_for`, but it's missing in std. This PR adds an implementation, following the status quo of using std.os.CLOCK.REALTIME in the pthread case (i.e. Futex) A follow-up patch moving futex/condition stuff to monotonic clocks where available seems like a good idea. This would involve conditionally exposing more functions and constants through std.c and std.os. For instance, Chromium picks `pthread_cond_timedwait_relative_np` on macOS and `clock_gettime(CLOCK_MONOTONIC...)` on BSD's. Tested on Windows 11, macOS 12.2.1 and Linux (with/without libc) * Sleep in the single threaded case, handle timeout overflow in the Windows case and address a race condition in the AtomicCondition case. |
||
|---|---|---|
| .. | ||
| AutoResetEvent.zig | ||
| Condition.zig | ||
| Futex.zig | ||
| Mutex.zig | ||
| ResetEvent.zig | ||
| RwLock.zig | ||
| Semaphore.zig | ||
| StaticResetEvent.zig | ||