Skip to content

Fix dispatch time comparisons #5078

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

Merged
merged 2 commits into from
Oct 13, 2016

Conversation

lilyball
Copy link
Contributor

This PR does two things:

  1. It makes < comparisons on DispatchWallTime not crash.
  2. It makes < comparisons against DispatchTime.distantFuture and DispatchWallTime.distantFuture behave as expected.

Fixes half of SR-2807.

@moiseev
Copy link
Contributor

moiseev commented Sep 30, 2016

/cc @mwwa

@@ -73,8 +72,12 @@ public struct DispatchWallTime : Comparable {
}

public func <(a: DispatchWallTime, b: DispatchWallTime) -> Bool {
if a.rawValue == ~0 || b.rawValue == ~0 { return false }
return -Int64(a.rawValue) < -Int64(b.rawValue)
if b.rawValue == ~0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Drive-by nit: indenting mismatch (this file uses \t).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh weird, I have a Vim plugin that's supposed to auto-detect this sort of thing but apparently it doesn't work anymore >_<

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR updated.

@das
Copy link

das commented Oct 3, 2016

@mwwa should review this.

The Linux overlay appears to have the same issue, can you please make a PR with the same change there ?

@lilyball
Copy link
Contributor Author

lilyball commented Oct 4, 2016

@das I already submitted swiftlang/swift-corelibs-libdispatch#182

@lilyball lilyball force-pushed the dispatch_time_comparisons branch from 506816f to 87bed5d Compare October 4, 2016 00:44
@lilyball
Copy link
Contributor Author

Is there anything blocking this from being reviewed?

@moiseev
Copy link
Contributor

moiseev commented Oct 12, 2016

@swift-ci Please smoke test

@moiseev
Copy link
Contributor

moiseev commented Oct 12, 2016

@kballard Thanks for bringing this up. I guess Matt just hasn't had time to review it yet.

@mwwa
Copy link
Contributor

mwwa commented Oct 12, 2016

Yeah, I've been out of the country for two weeks. I'll try and get to this today/tomorrow.

@mwwa
Copy link
Contributor

mwwa commented Oct 13, 2016

This looks good to me. @moiseev, can you merge?

@moiseev moiseev merged commit 301510e into swiftlang:master Oct 13, 2016
@lilyball lilyball deleted the dispatch_time_comparisons branch October 14, 2016 00:17
@lilyball
Copy link
Contributor Author

As @das suggested on my other PR, this should probably be put into swift-3. Is there anything I need to do to make this happen?

@gparker42
Copy link
Contributor

A PR with a cherrypick to the swift-3.0-branch may help push that forward.

lilyball added a commit to lilyball/swift that referenced this pull request Oct 14, 2016
* [Dispatch] Don't crash when comparing DispatchWallTimes with <

* [Dispatch] Make comparisons with distantFuture work as expected
@lilyball
Copy link
Contributor Author

Cherry-pick submitted as #5298.

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.

6 participants