zig/lib/std/Thread
cryptocode 531d5b213f
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.
2022-04-08 13:26:56 -05:00
..
AutoResetEvent.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
Condition.zig std: add Thread.Condition.timedWait (#11352) 2022-04-08 13:26:56 -05:00
Futex.zig zig fmt: remove trailing whitespace on doc comments 2022-04-05 18:08:33 +03:00
Mutex.zig std.Thread.Mutex: change API to lock() and unlock() 2021-11-09 18:31:03 -07:00
ResetEvent.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
RwLock.zig update RwLock to use static initialization (#10838) 2022-02-08 23:35:48 -05:00
Semaphore.zig std: add test for Thread.Semaphore 2022-01-29 20:30:53 +00:00
StaticResetEvent.zig std: rename sched_yield to yield and move it to std.Thread 2022-02-27 15:34:02 -05:00