Do run loops use an operation queue under the hood?
When I dispatch to the mian queue, I know it will run on the mian thread, which means it will be handled b the main thread's run loop. But is the other way around correct?
More specific question, is it possible somehow that the following code will return true
?
OperationQueue.current != OperationQueue.main && Thread.isMainThread
I tried to do for example to dispatch to the main thread using a timer.
myQueue.sync {
let timer = Timer(timeInterval: 1, repeats: false) { _ in
let curr = OperationQueue.current
let main = OperationQueue.main
print("\(String(describing: curr)) \(main)")
}
RunLoop.main.add(timer, forMode: .common)
}
And got the same pointer. But maybe some other way of dispatching to the main run loop will give different results, possibly that is why OperationQueue.current
can return nil
.