Revision: 7787
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7787&view=rev
Author:   hofman
Date:     2012-11-05 11:05:30 +0000 (Mon, 05 Nov 2012)
Log Message:
-----------
use dispatch queue as lock for synchronizer

Modified Paths:
--------------
    trunk/SKPDFSynchronizer.h
    trunk/SKPDFSynchronizer.m

Modified: trunk/SKPDFSynchronizer.h
===================================================================
--- trunk/SKPDFSynchronizer.h   2012-11-05 10:51:26 UTC (rev 7786)
+++ trunk/SKPDFSynchronizer.h   2012-11-05 11:05:30 UTC (rev 7787)
@@ -51,6 +51,7 @@
     id <SKPDFSynchronizerDelegate> delegate;
     
     dispatch_queue_t queue;
+    dispatch_queue_t lockQueue;
     
     NSString *fileName;
     NSString *syncFileName;

Modified: trunk/SKPDFSynchronizer.m
===================================================================
--- trunk/SKPDFSynchronizer.m   2012-11-05 10:51:26 UTC (rev 7786)
+++ trunk/SKPDFSynchronizer.m   2012-11-05 11:05:30 UTC (rev 7787)
@@ -69,6 +69,7 @@
     self = [super init];
     if (self) {
         queue = NULL;
+        lockQueue = 
dispatch_queue_create("net.sourceforge.skim-app.lockQueue.SKPDFSynchronizer", 
NULL);
         
         fileName = nil;
         syncFileName = nil;
@@ -92,6 +93,8 @@
 - (void)dealloc {
     if (queue) dispatch_release(queue);
     queue = NULL;
+    if (lockQueue) dispatch_release(lockQueue);
+    lockQueue = NULL;
     SKDESTROY(fileManager);
     SKDESTROY(pages);
     SKDESTROY(lines);
@@ -124,17 +127,17 @@
 }
 
 - (NSString *)fileName {
-    NSString *file = nil;
-    @synchronized(self) {
+    NSString __block *file = nil;
+    dispatch_sync(lockQueue, ^{
         file = [[fileName retain] autorelease];
-    }
+    });
     return file;
 }
 
 - (void)setFileName:(NSString *)newFileName {
     // we compare filenames in canonical form throughout, so we need to make 
sure fileName also is in canonical form
     newFileName = [[newFileName stringByResolvingSymlinksInPath] 
stringByStandardizingPath];
-    @synchronized(self) {
+    dispatch_async(lockQueue, ^{
         if (fileName != newFileName) {
             if ([fileName isEqualToString:newFileName] == NO) {
                 SKDESTROY(syncFileName);
@@ -143,34 +146,34 @@
             [fileName release];
             fileName = [newFileName retain];
         }
-    }
+    });
 }
 
 - (NSString *)syncFileName {
-    NSString *file = nil;
-    @synchronized(self) {
+    NSString __block *file = nil;
+    dispatch_sync(lockQueue, ^{
         file = [[syncFileName retain] autorelease];
-    }
+    });
     return file;
 }
 
 // this should only be used from the server thread
 - (void)setSyncFileName:(NSString *)newSyncFileName {
-    @synchronized(self) {
+    dispatch_async(lockQueue, ^{
         if (syncFileName != newSyncFileName) {
             [syncFileName release];
             syncFileName = [newSyncFileName retain];
         }
         [lastModDate release];
         lastModDate = [(syncFileName ? [[fileManager 
attributesOfItemAtPath:syncFileName error:NULL] fileModificationDate] : nil) 
retain];
-    }
+    });
 }
 
 - (NSDate *)lastModDate {
-    NSDate *date = nil;
-    @synchronized(self) {
+    NSDate __block *date = nil;
+    dispatch_sync(lockQueue, ^{
         date = [[lastModDate retain] autorelease];
-    }
+    });
     return date;
 }
 

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


------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to