-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
[WIP] Task.sleep(.max) awakes immediately #69118
Conversation
fprintf(stderr, "[%s:%d](%s) monotonic time mask, | mask: %llu\n", __FILE_NAME__, __LINE__, __FUNCTION__, DISPATCH_UP_OR_MONOTONIC_TIME_MASK); | ||
fprintf(stderr, "[%s:%d](%s) monotonic time mask, value | mask: %llu\n", __FILE_NAME__, __LINE__, __FUNCTION__, value | DISPATCH_UP_OR_MONOTONIC_TIME_MASK); | ||
// return value | DISPATCH_UP_OR_MONOTONIC_TIME_MASK; | ||
return value; // FIXME: sure this "works" but that's not the right fix I suppose... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this "works" but seems quite wrong... I was poking around in the withDeadline impl here but tbh not entirely sure where the issue resides... might be best for you @phausler to have a look at the swift_task_enqueueGlobalWithDeadlineImpl
and make it pass the added tests now
let t = Task.detached { | ||
print("Run infinite sleep") | ||
try? await Task.sleep(for: .nanoseconds(UInt64.max)) | ||
print("Infinite sleep done (cancelled: \(Task.isCancelled)) @ \(#function)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should adjust it on the Swift side (at the point of concrete clocks) to clamp the value there; because testing it like this gets a duration of 709551615000000000 seconds, 18446744073 attoseconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm so just cap it at Int64.max on the swift side perhaps...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, that seems reasonable to me (or cap and loop)
Task.sleep(nanoseconds: .max)
returns immediately #59174For now reproducing the issue and need to figure out why dispatch behaves like this and what we want to do about it.