11 Commits

Author SHA1 Message Date
Derek Mauro
de9ab52205 No-op changes to relative timeout support code.
PiperOrigin-RevId: 847827629
Change-Id: I84dec0fafa6cdbb8ffee013f9d5ad9b3cb977ee4
2025-12-22 11:19:58 -08:00
Evan Brown
93763764d7 Disable flaky test cases in kernel_timeout_internal_test.
PiperOrigin-RevId: 645054874
Change-Id: Ic4a820b47edfa71bd3e1f149d54f00ac3c1d16a6
2024-06-20 09:12:48 -07:00
Derek Mauro
ac810bee5a Remove test references to absl::SharedBitGen, which was never part of
the open source release. This was only used in tests that never ran
as part in the open source release.

PiperOrigin-RevId: 636167506
Change-Id: Iafc33bd768307fe9ee77b181369635012abf2245
2024-05-22 08:00:33 -07:00
Derek Mauro
7aef7808d6 kernel_timeout_test: Add Apple to the list of slow platforms because
it runs on non-dedicated Kokoro

PiperOrigin-RevId: 558874605
Change-Id: Iba35f558ab8c967f98a3176af056e76341fb67c3
2023-08-21 12:53:37 -07:00
Derek Mauro
c5f310de3b Don't override clock_gettime in the KernelTimeout and Waiter
tests under sanitizers. The overrides break the sanitizers.

PiperOrigin-RevId: 524037272
Change-Id: I85b87d3870c488cb316505e94b394c6f98e9f60f
2023-04-13 10:25:56 -07:00
Derek Mauro
c23acb9b56 Synchronization: Consolidate the logic for whether steady clocks are supported
for relative timeouts

PiperOrigin-RevId: 523789416
Change-Id: Ide4cfdcae9ea7bffca3355c80ea9c8833a9536e6
2023-04-12 13:27:28 -07:00
Derek Mauro
1a72ea7bb8 Synchronization: Support true relative timeouts using the POSIX
proposed standard pthread_cond_clockwait() and sem_clockwait().
These are currently implemented in glibc >= 2.30.

These methods take a clock and use an absolute time with reference
to that clock, so KernelTimeout now can produce these values.

PiperOrigin-RevId: 522824226
Change-Id: Ife98713f6f95d800b1f8e52d5364a3dbebc4f8a6
2023-04-08 09:52:56 -07:00
Tom Rybka
0697762c62 Increase the timeout of Windows for the kernel timeout tests.
Windows tests often run in Emulation, and even with KVM we can still timeout.

PiperOrigin-RevId: 517192968
Change-Id: I3b4e435f8ac8ad1e7eab6f043c051fa75efed64b
2023-03-16 12:20:51 -07:00
Derek Mauro
7f47b00fca Synchronization: Change KernelTimeout to always store absolute
timeouts, but when a relative timeout is provided, the timeout is an
absolute timeout against a steady clock (when possible). This allows
methods that return relative timeouts to automatically recompute the
remaining duration, for instance, on suprious wakeups.

PiperOrigin-RevId: 516304139
Change-Id: I7d739cb50dd749eba5dba7ac6c34d18dc53703ed
2023-03-13 13:24:46 -07:00
Derek Mauro
0372af19f2 Add KernelTimeout methods that convert the timeout to the
std::chrono methods used by std::condition_variable.

A followup change will add an implemention of
synchronization_internal::Waiter that can use
std:mutex/std::condition_variable to implement the per-thread
semaphore that absl::Mutex waits on. This implementation may at some
point become the default on platforms such as Windows where there
doesn't seem to be an easy way of supporting real absolute timeouts. In
this case we can defer to their standard library to implement correct
support.
PiperOrigin-RevId: 510204786
Change-Id: Icf4d695013fd060abbd53dae23e71ea36f731565
2023-02-16 11:53:15 -08:00
Derek Mauro
fa4855403c Rewrite KernelTimeout to support both absolute and relative timeouts
APIs that take KernelTimeout as a parameter can now query if an
absolute or relative timeout was requested. If the underlying API can
only use one type of timeout, the code will do a reasonable
conversion.

The goal is to eventually enable the possibility of using wait times
that are based on monotonic clocks that are safe against system clock
steps.

PiperOrigin-RevId: 508541507
Change-Id: Id08bf13515f3e1bfd78d88393cde98a6fd3ef72c
2023-02-09 19:45:48 -08:00