Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Skip thread-safety check when running on dispatch queues.
Browse files Browse the repository at this point in the history
  • Loading branch information
snej committed Jul 29, 2014
1 parent d1c436d commit 9838b4a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/FMDatabase.m
Expand Up @@ -890,17 +890,25 @@ - (void)setInUse:(BOOL)b {
}

- (BOOL) beginUse {
// Equivalent to NSAssert, but not disabled by NS_BLOCK_ASSERTIONS:
BOOL ok;
if (dispatchQueue) {
#if 1
ok = YES;
#else
// This check doesn't work if the current queue is separate from dispatchQueue but has
// dispatchQueue as its target queue. This is a legal setup but will trigger the
// exception. There's no way to detect this using the public API (I believe) so I have to
// just skip the check entirely when using dispatch queues.
_Pragma("clang diagnostic push")
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
ok = dispatch_get_current_queue() == dispatchQueue;
_Pragma("clang diagnostic pop")
#endif
} else {
ok = (BOOL)pthread_equal(pthread_self(), homeThread);
}
if (!ok) {
// Equivalent to NSAssert, but not disabled by NS_BLOCK_ASSERTIONS:
[[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd
object:self
file:@(__FILE__)
Expand Down

0 comments on commit 9838b4a

Please sign in to comment.