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:
Richard Frith-MacDonald 2010-02-05 11:41:24 +00:00
parent 1a353d2514
commit 9f98d4c443
2 changed files with 30 additions and 23 deletions

View file

@ -113,6 +113,10 @@ typedef NSInteger NSOperationQueuePriority;
/** <override-subclass/>
* This is the method which actually performs the operation ...
* 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
* instead of (or as well as) the -main method.
*/

View file

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