I am trying to write some thread safe methods so I am using:
...
dispatch_queue_t main = dispatch_get_main_queue();
dispatch_sync(main,^{
[self doSomethingInTheForeground];
});
...
But If I am on the main thread that is not necessary, and I can skip all those dispatch calls, so I would like to know what thread I currently am on. How can I know this?
Or, perhaps it does not make difference (in performance) doing it?
Is it ok to do this comparison?
if (dispatch_get_main_queue() == dispatch_get_current_queue()){...}