Revision: 12986
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12986&view=rev
Author:   hofman
Date:     2008-03-06 10:18:02 -0800 (Thu, 06 Mar 2008)

Log Message:
-----------
Start main queue operations in bulk rather than one by one, also reduces a lot 
of locks.

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMainThreadOperationQueue.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMainThreadOperationQueue.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMainThreadOperationQueue.m      
2008-03-06 17:26:06 UTC (rev 12985)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMainThreadOperationQueue.m      
2008-03-06 18:18:02 UTC (rev 12986)
@@ -63,6 +63,7 @@
         [nc addObserver:self selector:@selector(handleAppTerminate:) 
name:NSApplicationWillTerminateNotification object:NSApp];
         
         // this lock protects all of the collection ivars
+        // @@ CMH: is this necessary, as we're only active on the main thread?
         _queueLock = OS_SPINLOCK_INIT;
         
         // pending operations
@@ -143,25 +144,22 @@
 {
     NSCAssert(pthread_main_np() != 0, @"incorrect thread for main queue");
     FVMainThreadOperationQueue *queue = info;
+    NSMutableArray *operations = [[NSMutableArray alloc] init];
     
     OSSpinLockLock(&(queue->_queueLock));
     while ([queue->_pendingOperations count]) {
         
         FVOperation *op = [queue->_pendingOperations pop];
-        BOOL shouldLock = NO;
         
         if (NO == [op isCancelled] && NO == [queue->_activeOperations 
containsObject:op]) {
             [queue->_activeOperations addObject:op];
-            // avoid deadlock: next call will (probably) trigger 
finishedOperation: on this thread
-            OSSpinLockUnlock(&(queue->_queueLock));
-            shouldLock = YES;
-            [op start];
+            [operations addObject:op];
         }
-                
-        if (shouldLock)
-            OSSpinLockLock(&(queue->_queueLock));
     }
     OSSpinLockUnlock(&(queue->_queueLock));
+    
+    [operations makeObjectsPerformSelector:@selector(start)];
+    [operations release];
 }
 
 - (void)setThreadPriority:(double)p;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to