diff --git a/ChangeLog b/ChangeLog index af5cbf369..a4de220d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-01-05 Richard Frith-Macdonald + + * Source/NSRunLoop.m: check for performers in thread even if there are + no input sources available. + * Source/unix/GSRunLoopCtxt.m: Add diagnostics + * Source/win32/GSRunLoopCtxt.m: Add diagnostics + * Testing/thread.m: Change to allow perform in maion thrad to take + place and program to terminate. + 2009-01-04 Richard Frith-Macdonald * Source/mframe/sparc64/generic: guess at a config diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index c58e069d2..ef8b61465 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -1129,9 +1129,18 @@ static inline BOOL timerInvalidated(NSTimer *t) GSPrivateNotifyIdle(); /* * Pause for as long as possible (up to the limit date) + * Call the polling method so we notice thread notifications + * that methods should be performed in this loop. */ - [NSThread sleepUntilDate: limit_date]; ti = [limit_date timeIntervalSinceNow]; + if (context == nil) + { + context = [[GSRunLoopCtxt alloc] initWithMode: mode + extra: _extra]; + NSMapInsert(_contextMap, context->mode, context); + RELEASE(context); + } + [context pollUntil: (int)(ti * 1000) within: nil]; GSPrivateCheckTasks(); if (context != nil) { diff --git a/Source/unix/GSRunLoopCtxt.m b/Source/unix/GSRunLoopCtxt.m index 44f6775ea..5794ede04 100644 --- a/Source/unix/GSRunLoopCtxt.m +++ b/Source/unix/GSRunLoopCtxt.m @@ -571,6 +571,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) { if (fd == threadInfo->inputFd) { + NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); [threadInfo fire]; watcher = nil; } @@ -950,6 +951,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) if (fdIndex == threadInfo->inputFd) { + NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); [threadInfo fire]; watcher = nil; } diff --git a/Source/win32/GSRunLoopCtxt.m b/Source/win32/GSRunLoopCtxt.m index 33f3575f4..a2eea773b 100644 --- a/Source/win32/GSRunLoopCtxt.m +++ b/Source/win32/GSRunLoopCtxt.m @@ -527,6 +527,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = if (handle == threadInfo->event) { watcher = nil; + NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); [threadInfo fire]; } else diff --git a/Testing/thread.m b/Testing/thread.m index f0c93ea7e..4292d9be9 100644 --- a/Testing/thread.m +++ b/Testing/thread.m @@ -12,6 +12,7 @@ NSLock *lock = nil; unsigned retainReleaseThreads = 0; +unsigned fireCount = 0; @interface XX : NSObject - (void) fire; @@ -23,6 +24,7 @@ unsigned retainReleaseThreads = 0; - (void) fire { NSLog(@"Got here"); + fireCount++; } - (void) retainRelease: (id)obj { @@ -34,10 +36,11 @@ unsigned retainReleaseThreads = 0; [obj retain]; [obj release]; } + NSLog(@"Done %d retain/releases in thread %@", i, [NSThread currentThread]); [lock lock]; retainReleaseThreads++; [lock unlock]; - NSLog(@"Done %d retain/releases in thread %@", i, [NSThread currentThread]); + NSLog(@"Finished thread %@", [NSThread currentThread]); } - (void) setup { @@ -105,7 +108,7 @@ int main(int argc, char **argv, char **env) [lock unlock]; // Allow other thread to proceed. [[NSRunLoop currentRunLoop] runUntilDate: - [NSDate dateWithTimeIntervalSinceNow: 10.0]]; + [NSDate dateWithTimeIntervalSinceNow: 30.0]]; NSLog(@"Done main thread"); @@ -113,7 +116,8 @@ int main(int argc, char **argv, char **env) { NSLog(@"Waiting for all 5 retainRelease threads to complete (%d)", retainReleaseThreads); - [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + [[NSRunLoop currentRunLoop] acceptInputForMode: NSDefaultRunLoopMode + beforeDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; } if ([o retainCount] != 1) {