Support shrinking number of threads in pool.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@36753 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-06-25 09:22:49 +00:00
parent 4782d743ed
commit dfadd70968

View file

@ -221,13 +221,7 @@ best(NSMutableArray *a)
- (void) setThreads: (NSUInteger)max
{
[poolLock lock];
if (max != maxThreads)
{
maxThreads = max;
while ([threads count] > maxThreads)
{
}
}
maxThreads = max;
[poolLock unlock];
}
@ -253,6 +247,17 @@ best(NSMutableArray *a)
format: @"-unacquireThread: called too many times"];
}
((GSIOThread*)aThread)->count--;
if (0 == ((GSIOThread*)aThread)->count
&& [threads count] > maxThreads)
{
[aThread retain];
[threads removeObjectIdenticalTo: aThread];
[aThread performSelector: @selector(terminate:)
onThread: aThread
withObject: [NSDate date]
waitUntilDone: NO];
[aThread release];
}
}
[poolLock unlock];
}