Skip to content
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

Ubuntu compilation error #66

Open
sage444 opened this issue Apr 30, 2019 · 3 comments
Open

Ubuntu compilation error #66

sage444 opened this issue Apr 30, 2019 · 3 comments

Comments

@sage444
Copy link

sage444 commented Apr 30, 2019

/home/user/Project/.build/checkouts/Hydra.git-8391472609009747209/Sources/Hydra/Promise+Await.swift:99:20: error: binary operator '!=' cannot be applied to two 'DispatchQueue' operands
                guard self.queue != DispatchQueue.main else {
                      ~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~

Swift version 5.0.1 (swift-5.0.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Ubuntu 16.04.6 LTS
@sage444
Copy link
Author

sage444 commented Apr 30, 2019

I'm looking for solution in code and found that this check self.queue != DispatchQueue.main is not relevant for the rest of function. Let me clarify

		guard self.queue != DispatchQueue.main else { // there is check of self.queue and main 
...
		_ = semaphore.wait(timeout: .distantFuture) // call to semaphore.wait in outside context not self.queue 

@sage444
Copy link
Author

sage444 commented Apr 30, 2019

The root of this issue is that DispatchQueue is not Equatable on Linux. SO recommends using of setSpecific/getSpecific to tag queue and later distinguish but in my opinion for this particular case easiest solution is to use Thread.isMainThread

@sage444
Copy link
Author

sage444 commented Apr 30, 2019

I ended up removing that check for main queue:). After that.

The worst case scenario is calling await from some thread and providing the same thread as context that leads to little disaster:). AFAIK GCD's API does't provide functions for easy mitigation from this case. The correct solution requires additional queue for all calls from outside to ensure that we aren't locking sensitive threads, but it's more foolproofing in my opinion.

Calling semaphore.wait in main thread is not as bad as first case and I can imagine some practical reasons to do it.

rinsuki added a commit to rinsuki/Hydra that referenced this issue Nov 18, 2019
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 a pull request may close this issue.

1 participant