diff options
| author | cryptocode <cryptocode@zolo.io> | 2022-04-08 20:26:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-08 13:26:56 -0500 |
| commit | 531d5b213f5cc7450c56bea3fc2050dda5794067 (patch) | |
| tree | ba2ab7d1e4362d3642dab55ec9c05a7c7fccbdf0 /src/Cache.zig | |
| parent | 6ae8fe193bd5397b9fceea98ba684d9d870286cf (diff) | |
| download | zig-531d5b213f5cc7450c56bea3fc2050dda5794067.tar.gz zig-531d5b213f5cc7450c56bea3fc2050dda5794067.zip | |
std: add Thread.Condition.timedWait (#11352)
* 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.
Diffstat (limited to 'src/Cache.zig')
0 files changed, 0 insertions, 0 deletions
