mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-19 18:11:16 +00:00
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:
parent
4782d743ed
commit
dfadd70968
1 changed files with 12 additions and 7 deletions
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue