Skip to content

Loading…

Remove dispatch_get_current_queue() iOS6 deprecation notices. #65

Closed
wants to merge 1 commit into from

6 participants

@uxp
uxp commented

dispatch_get_current_queue is deprecated in iOS6. Change all occurances
of that method to dispatch_get_global_queue() with a default priority,
which essentially does the same thing.

@uxp uxp Remove dispatch_get_current_queue() iOS6 deprecation notices.
dispatch_get_current_queue is deprecated in iOS6. Change all occurances
of that method to dispatch_get_global_queue() with a default priority,
which essentially does the same thing. I don't think LogWorkerThread
ever needs to touch the main thread anyways, so there shouldn't be
an issue here.  Apple says dispatch_get_current_queue has never been
reliable anyways.
d072856
@ArloL

+1

@andrask

+1

@robbiehanson

The patch is incorrect. I'm working on a fix now.

@andrask

Thanks! I +1-ed cause these warnings are pretty annoying so it will be good to clean them up. Please allow me one question: why does code suppose that methods can be called from inside the logger queue. IMHO any log request should be queued and executed in sync or async according to the current logging policy. If someone decides to do logging inside a logger implementation, then they should cease doing so. You should be able to get rid of a zillion "if" statements this way. :)

@robbiehanson

one question: why does code suppose that methods can be called from inside the logger queue.

Since it's open source, is supposes that other's may alter/extend the code. If they do, and then attempt to access certain ivar's via self.ivar (as opposed to direct access as recommended), the code attempts to "do the right thing". However, repository code doesn't go through these methods.

This was a great question btw, and got me thinking about it. So I've now changed the getter/setter methods to throw an assertion if one doesn't directly access the ivars (which is now required). Thus I have removed several of the "if" statements. However, I've maintained some assertions (which will automatically get compiled out in release builds) because it can be very difficult to track down deadlock situations.

@rvenable

There are still dispatch_get_current_queue warnings in DDAbstractDatabaseLogger.m

@uxp uxp deleted the uxp:depricated_current_queue branch
@bpoplauschi bpoplauschi removed the Started label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 9, 2012
  1. @uxp

    Remove dispatch_get_current_queue() iOS6 deprecation notices.

    uxp committed
    dispatch_get_current_queue is deprecated in iOS6. Change all occurances
    of that method to dispatch_get_global_queue() with a default priority,
    which essentially does the same thing. I don't think LogWorkerThread
    ever needs to touch the main thread anyways, so there shouldn't be
    an issue here.  Apple says dispatch_get_current_queue has never been
    reliable anyways.
Showing with 29 additions and 29 deletions.
  1. +12 −12 Lumberjack/DDAbstractDatabaseLogger.m
  2. +5 −5 Lumberjack/DDFileLogger.m
  3. +3 −3 Lumberjack/DDLog.m
  4. +9 −9 Lumberjack/DDTTYLogger.m
View
24 Lumberjack/DDAbstractDatabaseLogger.m
@@ -239,7 +239,7 @@ - (void)createAndStartDeleteTimer
- (NSUInteger)saveThreshold
{
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
{
return saveThreshold;
}
@@ -279,7 +279,7 @@ - (void)setSaveThreshold:(NSUInteger)threshold
}
};
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
block();
else
dispatch_async(loggerQueue, block);
@@ -287,7 +287,7 @@ - (void)setSaveThreshold:(NSUInteger)threshold
- (NSTimeInterval)saveInterval
{
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
{
return saveInterval;
}
@@ -362,7 +362,7 @@ - (void)setSaveInterval:(NSTimeInterval)interval
}
};
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
block();
else
dispatch_async(loggerQueue, block);
@@ -370,7 +370,7 @@ - (void)setSaveInterval:(NSTimeInterval)interval
- (NSTimeInterval)maxAge
{
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
{
return maxAge;
}
@@ -451,7 +451,7 @@ - (void)setMaxAge:(NSTimeInterval)interval
}
};
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
block();
else
dispatch_async(loggerQueue, block);
@@ -459,7 +459,7 @@ - (void)setMaxAge:(NSTimeInterval)interval
- (NSTimeInterval)deleteInterval
{
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
{
return deleteInterval;
}
@@ -533,7 +533,7 @@ - (void)setDeleteInterval:(NSTimeInterval)interval
}
};
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
block();
else
dispatch_async(loggerQueue, block);
@@ -541,7 +541,7 @@ - (void)setDeleteInterval:(NSTimeInterval)interval
- (BOOL)deleteOnEverySave
{
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
{
return deleteOnEverySave;
}
@@ -564,7 +564,7 @@ - (void)setDeleteOnEverySave:(BOOL)flag
deleteOnEverySave = flag;
};
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
block();
else
dispatch_async(loggerQueue, block);
@@ -581,7 +581,7 @@ - (void)savePendingLogEntries
[self performSaveAndSuspendSaveTimer];
}};
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
block();
else
dispatch_async(loggerQueue, block);
@@ -594,7 +594,7 @@ - (void)deleteOldLogEntries
[self performDelete];
}};
- if (dispatch_get_current_queue() == loggerQueue)
+ if (dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) == loggerQueue)
block();
else
dispatch_async(loggerQueue, block);
View
10 Lumberjack/DDFileLogger.m
@@ -528,7 +528,7 @@ - (unsigned long long)maximumFileSize
// Note: The internal implementation should access the maximumFileSize variable directly,
// but if we forget to do this, then this method should at least work properly.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
return maximumFileSize;
@@ -562,7 +562,7 @@ - (void)setMaximumFileSize:(unsigned long long)newMaximumFileSize
}};
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -586,7 +586,7 @@ - (NSTimeInterval)rollingFrequency
// Note: The internal implementation should access the rollingFrequency variable directly,
// but if we forget to do this, then this method should at least work properly.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
return rollingFrequency;
@@ -620,7 +620,7 @@ - (void)setRollingFrequency:(NSTimeInterval)newRollingFrequency
}};
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -700,7 +700,7 @@ - (void)rollLogFile
[self rollLogFileNow];
}};
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
View
6 Lumberjack/DDLog.m
@@ -868,7 +868,7 @@ - (id)initWithLogMsg:(NSString *)msg
machThreadID = pthread_mach_thread_np(pthread_self());
- queueLabel = dd_str_copy(dispatch_queue_get_label(dispatch_get_current_queue()));
+ queueLabel = dd_str_copy(dispatch_queue_get_label(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)));
threadName = [[NSThread currentThread] name];
}
@@ -996,7 +996,7 @@ - (void)logMessage:(DDLogMessage *)logMessage
// So direct access to the formatter is only available if requested from the loggerQueue.
// In all other circumstances we need to go through the loggingQueue to get the proper value.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
return formatter;
@@ -1038,7 +1038,7 @@ - (void)setLogFormatter:(id <DDLogFormatter>)logFormatter
}
}};
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
View
18 Lumberjack/DDTTYLogger.m
@@ -867,7 +867,7 @@ - (BOOL)colorsEnabled
// The design of this method is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
return colorsEnabled;
@@ -903,7 +903,7 @@ - (void)setColorsEnabled:(BOOL)newColorsEnabled
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -956,7 +956,7 @@ - (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColo
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -992,7 +992,7 @@ - (void)setForegroundColor:(OSColor *)txtColor backgroundColor:(OSColor *)bgColo
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -1037,7 +1037,7 @@ - (void)clearColorsForFlag:(int)mask context:(int)context
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -1065,7 +1065,7 @@ - (void)clearColorsForTag:(id <NSCopying>)tag
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -1091,7 +1091,7 @@ - (void)clearColorsForAllFlags
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -1117,7 +1117,7 @@ - (void)clearColorsForAllTags
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
@@ -1144,7 +1144,7 @@ - (void)clearAllColors
// The design of the setter logic below is taken from the DDAbstractLogger implementation.
// For documentation please refer to the DDAbstractLogger implementation.
- dispatch_queue_t currentQueue = dispatch_get_current_queue();
+ dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
if (currentQueue == loggerQueue)
{
block();
Something went wrong with that request. Please try again.