tweak for OSX compatibility

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29480 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-02-05 11:41:24 +00:00
parent 845bfe3c4c
commit ad5c68529b
2 changed files with 30 additions and 23 deletions

View file

@ -113,6 +113,10 @@ typedef NSInteger NSOperationQueuePriority;
/** <override-subclass/> /** <override-subclass/>
* This is the method which actually performs the operation ... * This is the method which actually performs the operation ...
* the default implementation does nothing.<br /> * the default implementation does nothing.<br />
* You MUST ensure that your implemention of -main does not raise any
* exception or call [NSThread-exit] as either of these will terminate
* the operation prematurely resulting in the operation never reaching
* the -isFinished state.<br />
* If you are writing a concurrent subclass, you should override -start * If you are writing a concurrent subclass, you should override -start
* instead of (or as well as) the -main method. * instead of (or as well as) the -main method.
*/ */

View file

@ -360,7 +360,7 @@ static NSArray *empty = nil;
- (void) start - (void) start
{ {
CREATE_AUTORELEASE_POOL(pool); CREATE_AUTORELEASE_POOL(pool);
NSException *e = nil; double prio = [NSThread threadPriority];
[internal->lock lock]; [internal->lock lock];
NS_DURING NS_DURING
@ -393,24 +393,33 @@ static NSArray *empty = nil;
[self willChangeValueForKey: @"isExecuting"]; [self willChangeValueForKey: @"isExecuting"];
internal->executing = YES; internal->executing = YES;
[self didChangeValueForKey: @"isExecuting"]; [self didChangeValueForKey: @"isExecuting"];
}
NS_HANDLER
{
[internal->lock unlock];
[localException raise];
}
NS_ENDHANDLER
[internal->lock unlock];
NS_DURING NS_DURING
{
if (NO == [self isCancelled])
{ {
if (NO == [self isCancelled]) [NSThread setThreadPriority: internal->threadPriority];
{ [self main];
double prio = [NSThread threadPriority];
[NSThread setThreadPriority: internal->threadPriority];
[self main];
[NSThread setThreadPriority: prio];
}
} }
NS_HANDLER }
{ NS_HANDLER
e = localException; {
} [NSThread setThreadPriority: prio];
NS_ENDHANDLER; [localException raise];
}
NS_ENDHANDLER;
[internal->lock lock];
NS_DURING
{
/* Notify KVO system of changes to isExecuting and isFinished /* Notify KVO system of changes to isExecuting and isFinished
*/ */
[self willChangeValueForKey: @"isExecuting"]; [self willChangeValueForKey: @"isExecuting"];
@ -424,17 +433,11 @@ static NSArray *empty = nil;
} }
NS_HANDLER NS_HANDLER
{ {
if (e == nil) [internal->lock unlock];
{ [localException raise];
e = localException;
}
} }
NS_ENDHANDLER NS_ENDHANDLER
[internal->lock unlock]; [internal->lock unlock];
if (e != nil)
{
[e raise];
}
RELEASE(pool); RELEASE(pool);
} }