Improve perform in other threads

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27520 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-01-05 11:26:25 +00:00
parent 2cc2afa8ff
commit 7ae871d1ac
5 changed files with 29 additions and 4 deletions

View file

@ -1,3 +1,12 @@
2009-01-05 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <rfm@gnu.org>
* Source/mframe/sparc64/generic: guess at a config

View file

@ -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)
{

View file

@ -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;
}

View file

@ -527,6 +527,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
if (handle == threadInfo->event)
{
watcher = nil;
NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread");
[threadInfo fire];
}
else

View file

@ -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)
{