I am using an API where it is not entirely clear if the block is always executed on the main queue. If it is not, then I need to call the main queue synchronously.
How can I check if the block is already executing on the main queue? dispatch_get_current_queue()
is deprecated. Must I use dispatch_get_specific()
to get an comparable identifier?
The unique thing about the main queue is that it is always matched exactly to the main thread. So you can use [NSThread isMainThread]
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.