Skip to content

Add an additional case for clocks to sleep with a wallclock deadline #79139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

phausler
Copy link
Contributor

@phausler phausler commented Feb 4, 2025

This only modifies the runtime function swift_task_enqueueGlobalWithDeadline to take new clock primitive to interoperate with dispatch's wall clock values.

case swift_clock_id_wall:
struct timespec wall;
#if defined(__linux__) || defined(__APPLE__) || defined(__wasi__) || defined(__OpenBSD__) || defined(__FreeBSD__)
clock_gettime(CLOCK_REALTIME, &wall);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timespec_get(&wall, TIME_UTC) is the C standard API for this and is supported on Windows too.

case swift_clock_id_wall: {
struct timespec wall;
#if defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__wasi__)
clock_getres(CLOCK_REALTIME, &wall);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, timespec_getres(&wall, TIME_UTC) is standard and works on Windows too.

@phausler phausler force-pushed the pr/wall_clock_runtime branch from 1448d25 to 1c75060 Compare June 4, 2025 21:40
@phausler phausler requested a review from compnerd as a code owner June 4, 2025 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants