Ubuntu compilation error
/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
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
```
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
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.