adium 3828:225ea7da8e01: let's use this variable. warnings--;
commits at adium.im
commits at adium.im
Fri Apr 1 19:24:39 UTC 2011
details: http://hg.adium.im/adium/rev/225ea7da8e01
revision: 3828:225ea7da8e01
branch: AILoggerWithBlocks
author: Stephen Holt <sholt at adium.im>
date: Fri Apr 01 11:40:42 2011 -0700
let's use this variable. warnings--;
Subject: adium 3829:901b4c3afa07: "mainDispatchQueue" has nothing to do with the main thread. Let's call it "defaultDispatchQueue" instead.
details: http://hg.adium.im/adium/rev/901b4c3afa07
revision: 3829:901b4c3afa07
branch: AILoggerWithBlocks
author: Stephen Holt <sholt at adium.im>
date: Fri Apr 01 11:43:24 2011 -0700
"mainDispatchQueue" has nothing to do with the main thread. Let's call it "defaultDispatchQueue" instead.
Subject: adium 3830:3aecbdcb1acf: Don't block when all we want to do is ensure the SKIndexRef doesn't go away
details: http://hg.adium.im/adium/rev/3aecbdcb1acf
revision: 3830:3aecbdcb1acf
branch: AILoggerWithBlocks
author: Stephen Holt <sholt at adium.im>
date: Fri Apr 01 12:24:34 2011 -0700
Don't block when all we want to do is ensure the SKIndexRef doesn't go away
diffs (181 lines):
diff -r fd8847ab8685 -r 3aecbdcb1acf Source/AILoggerPlugin.m
--- a/Source/AILoggerPlugin.m Fri Apr 01 11:00:45 2011 -0700
+++ b/Source/AILoggerPlugin.m Fri Apr 01 12:24:34 2011 -0700
@@ -168,7 +168,7 @@
static NSString *logBaseAliasPath = nil;
#pragma mark Dispatch
-static dispatch_queue_t mainDispatchQueue;
+static dispatch_queue_t defaultDispatchQueue;
static dispatch_queue_t dirtyLogSetMutationQueue;
static dispatch_queue_t searchIndexQueue;
@@ -203,7 +203,7 @@
self.activeAppenders = [NSMutableDictionary dictionary];
self.dirtyLogSet = [NSMutableSet set];
- mainDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+ defaultDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dirtyLogSetMutationQueue = dispatch_queue_create("im.adium.AILoggerPlugin.dirtyLogSetMutationQueue", 0);
searchIndexQueue = dispatch_queue_create("im.adium.AILoggerPlugin.searchIndexFlushingQueue", 0);
@@ -381,7 +381,7 @@
- (void)prepareLogContentSearching
{
__block __typeof__(self) bself = self;
- dispatch_async(mainDispatchQueue, ^{
+ dispatch_async(defaultDispatchQueue, ^{
/* Load the index and start indexing to make it current
* If we're going to need to re-index all our logs from scratch, it will make
* things faster if we start with a fresh log index as well.
@@ -407,7 +407,7 @@
[self cancelIndexing];
- dispatch_group_async(loggerPluginGroup, mainDispatchQueue, ^{
+ dispatch_group_async(loggerPluginGroup, defaultDispatchQueue, ^{
dispatch_group_enter(closingIndexGroup);
[bself _closeLogIndex];
dispatch_group_leave(closingIndexGroup);
@@ -424,9 +424,9 @@
*/
[self _cancelClosingLogIndex];
__block __typeof__(self) bself = self;
- dispatch_sync(searchIndexQueue, blockWithAutoreleasePool(^{
- SKIndexRef _index = nil;
- if (!bself->logIndex) {
+ if (!logIndex) {
+ dispatch_sync(searchIndexQueue, blockWithAutoreleasePool(^{
+ SKIndexRef _index = nil;
NSString *logIndexPath = [bself _logIndexPath];
NSURL *logIndexURL = [NSURL fileURLWithPath:logIndexPath];
@@ -473,9 +473,8 @@
}
}
bself->logIndex = _index;
- }
- }));
-
+ }));
+ }
return logIndex;
}
@@ -496,7 +495,7 @@
NSLog(@"Canceling..");
if (logsToIndex) {
__block __typeof__(self) bself = self;
- dispatch_group_async(loggerPluginGroup, mainDispatchQueue, ^{
+ dispatch_group_async(loggerPluginGroup, defaultDispatchQueue, ^{
bself.indexingAllowed = NO;
dispatch_group_wait(logIndexingGroup, DISPATCH_TIME_FOREVER);
bself.logsToIndex = 0;
@@ -509,7 +508,7 @@
- (void)removePathsFromIndex:(NSSet *)paths
{
__block __typeof__(self) bself = self;
- dispatch_group_async(loggerPluginGroup, mainDispatchQueue, blockWithAutoreleasePool(^{
+ dispatch_group_async(loggerPluginGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
SKIndexRef logSearchIndex = [bself logContentIndex];
for (NSString *logPath in paths) {
@@ -1009,7 +1008,7 @@
if (![chat shouldLog]) return;
__block __typeof__(self) bself = self;
- dispatch_group_async(logAppendingGroup, mainDispatchQueue, blockWithAutoreleasePool(^{
+ dispatch_group_async(logAppendingGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
BOOL dirty = NO;
NSString *contentType = [content type];
NSString *date = [[[content date] dateWithCalendarFormat:nil timeZone:nil] ISO8601DateString];
@@ -1083,7 +1082,7 @@
[statusElement setAttributeNames:attributeKeys values:attributeValues];
- [[self _appenderForChat:chat] appendElement:statusElement];
+ [[bself _appenderForChat:chat] appendElement:statusElement];
dirty = YES;
}
@@ -1122,7 +1121,7 @@
//Don't create a new one if not needed
AIXMLAppender *appender = [self _existingAppenderForChat:chat];
if (dirty && appender)
- [self _markLogDirtyAtPath:[appender path] forChat:chat];
+ [bself _markLogDirtyAtPath:[appender path] forChat:chat];
dispatch_semaphore_signal(jobSemaphore);
}));
@@ -1327,9 +1326,12 @@
- (void)_cancelClosingLogIndex
{
- self.canCloseIndex = NO;
- dispatch_group_wait(closingIndexGroup, DISPATCH_TIME_FOREVER);
- self.canCloseIndex = YES;
+ __block __typeof__(self) bself = self;
+ dispatch_async(defaultDispatchQueue, ^{
+ bself.canCloseIndex = NO;
+ dispatch_group_wait(closingIndexGroup, DISPATCH_TIME_FOREVER);
+ bself.canCloseIndex = YES;
+ });
}
- (void)_dirtyAllLogs
@@ -1338,7 +1340,7 @@
dispatch_sync(dirtyLogSetMutationQueue, ^{
[bself.dirtyLogSet removeAllObjects];
});
- dispatch_group_async(loggerPluginGroup, mainDispatchQueue, blockWithAutoreleasePool(^{
+ dispatch_group_async(loggerPluginGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
dispatch_group_wait(logIndexingGroup, DISPATCH_TIME_FOREVER);
dispatch_group_wait(closingIndexGroup, DISPATCH_TIME_FOREVER);
dispatch_group_wait(logAppendingGroup, DISPATCH_TIME_FOREVER);
@@ -1399,7 +1401,7 @@
});
if (self.logsToIndex == 0){
- dispatch_async(mainDispatchQueue, ^{
+ dispatch_async(defaultDispatchQueue, ^{
// logsIndexed = 0;
OSAtomicCompareAndSwap64Barrier(logsIndexed, 0, (int64_t*)&logsIndexed);
[bself _didCleanDirtyLogs];
@@ -1451,7 +1453,7 @@
* 3. On 10.3, this means that logs' markup is indexed in addition to their text, which is undesireable.
*/
__block CFStringRef documentText = CopyTextContentForFile(NULL, (CFStringRef)logPath);
- dispatch_group_async(logIndexingGroup, mainDispatchQueue, blockWithAutoreleasePool(^{
+ dispatch_group_async(logIndexingGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
CFRetain(searchIndex);
if (documentText && bself.indexingAllowed) {
SKIndexAddDocumentWithText(searchIndex,
@@ -1566,12 +1568,12 @@
NSParameterAssert(path != nil);
NSParameterAssert(chat != nil);
__block __typeof__(self) bself = self;
- dispatch_async(mainDispatchQueue, ^{
+ dispatch_async(defaultDispatchQueue, ^{
dispatch_group_wait(logIndexingGroup, DISPATCH_TIME_FOREVER);
dispatch_async(dirtyLogSetMutationQueue, ^{
if (path && ![bself.dirtyLogSet containsObject:path]) {
[bself.dirtyLogSet addObject:path];
- dispatch_group_async(loggerPluginGroup, mainDispatchQueue, blockWithAutoreleasePool(^{
+ dispatch_group_async(loggerPluginGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
[bself _saveDirtyLogSet];
}));
}
@@ -1585,9 +1587,11 @@
__block __typeof__(self) bself = self;
dispatch_group_wait(logIndexingGroup, DISPATCH_TIME_FOREVER);
dispatch_async(searchIndexQueue, ^{
- if (bself->logIndex && bself.canCloseIndex) {
+ if (bself->logIndex) {
[bself _flushIndex:bself->logIndex];
- SKIndexClose(bself->logIndex);
+ if (bself.canCloseIndex) {
+ SKIndexClose(bself->logIndex);
+ }
bself->logIndex = nil;
}
});
More information about the commits
mailing list