Commits

Jens Alfke committed e833e9e

Allow MYDirectoryWatcher to run in additional runloop modes.

Comments (0)

Files changed (2)

MYDirectoryWatcher.h

     UInt64 _lastEventID;
     BOOL _historyDone;
     CFTimeInterval _latency;
+    NSMutableSet* _modes;
     FSEventStreamRef _stream;
 }
 
 
 @property (readonly,nonatomic) NSString* path;
 
-@property UInt64 lastEventID;
-@property CFTimeInterval latency;
+@property (nonatomic) UInt64 lastEventID;
+@property (nonatomic) CFTimeInterval latency;
+@property (retain, nonatomic) NSMutableSet* runLoopModes;
 
 - (BOOL) start;
 - (void) pause;

MYDirectoryWatcher.m

         _action = action;
         _latency = 5.0;
         _lastEventID = kFSEventStreamEventIdSinceNow;
+        _modes = [[NSMutableSet alloc] initWithObjects: (id)kCFRunLoopCommonModes, nil];
     }
     return self;
 }
     [self stop];
     [_path release];
     [_standardizedPath release];
+    [_modes release];
     [super dealloc];
 }
 
 }
 
 
-@synthesize path=_path, latency=_latency, lastEventID=_lastEventID;
+@synthesize path=_path, latency=_latency, lastEventID=_lastEventID, runLoopModes=_modes;
 
 - (NSString*) standardizedPath {
     return _standardizedPath;
                                       kFSEventStreamCreateFlagUseCFTypes);
         if( ! _stream )
             return NO;
-        FSEventStreamScheduleWithRunLoop(_stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+        Assert(_modes.count > 0);
+        for (NSString *mode in _modes)
+            FSEventStreamScheduleWithRunLoop(_stream, CFRunLoopGetCurrent(), (CFStringRef)mode);
         if( ! FSEventStreamStart(_stream) ) {
             [self stop];
             return NO;