Comparing dispatch_get_current_queue and dispatch_get_main_queue is explicitly forbidden by the documentation #20

Merged
merged 2 commits into from Feb 9, 2013

Conversation

Projects
None yet
2 participants
@JaviSoto
Contributor

JaviSoto commented Feb 8, 2013

Checking the right way if a method is invoked from the main thread. The GCD documentation states: (dispatch/queue.h)

When dispatch_get_current_queue() is called on the main thread, it may
or may not return the same value as dispatch_get_main_queue(). Comparing
the two is not a valid way to test whether code is executing on the
main thread.

odrobnik added a commit that referenced this pull request Feb 9, 2013

Merge pull request #20 from JaviSoto/master
Comparing dispatch_get_current_queue and dispatch_get_main_queue is explicitly forbidden by the documentation

@odrobnik odrobnik merged commit 45832cb into Cocoanetics:master Feb 9, 2013

@odrobnik

This comment has been minimized.

Show comment
Hide comment
@odrobnik

odrobnik Feb 9, 2013

Collaborator

I guess your approach is safer. Thank you for enhancing it!

Collaborator

odrobnik commented Feb 9, 2013

I guess your approach is safer. Thank you for enhancing it!

@odrobnik

This comment has been minimized.

Show comment
Hide comment
@odrobnik

odrobnik Feb 9, 2013

Actually you had a bug there. the [self isMainThread] always returns true because [NSThread mainThread] always returns a valid main thread. I fixed that in a later commit and removed the single-statement method. e5a4574

Actually you had a bug there. the [self isMainThread] always returns true because [NSThread mainThread] always returns a valid main thread. I fixed that in a later commit and removed the single-statement method. e5a4574

This comment has been minimized.

Show comment
Hide comment
@JaviSoto

JaviSoto Feb 9, 2013

Owner
Owner

JaviSoto replied Feb 9, 2013

This comment has been minimized.

Show comment
Hide comment
@odrobnik

odrobnik Feb 9, 2013

Not to worry. Either way thank you very much for your impetus! I learned quite a bit from this, even though it is slightly embarrassing having to go back into an article that many people have read and liked and make changes stemming from my own ignorance.

Not to worry. Either way thank you very much for your impetus! I learned quite a bit from this, even though it is slightly embarrassing having to go back into an article that many people have read and liked and make changes stemming from my own ignorance.

This comment has been minimized.

Show comment
Hide comment
@JaviSoto

JaviSoto Feb 9, 2013

Owner
Owner

JaviSoto replied Feb 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment