Make -drain: consider active threads

This commit is contained in:
rfm 2024-03-15 12:14:56 +00:00
parent 1a8c379be8
commit 4145d7e815
2 changed files with 5 additions and 5 deletions

View file

@ -59,8 +59,8 @@
*/
+ (GSThreadPool*) sharedPool;
/** Waits until the pool of operations is empty or until the specified
* timestamp. Returns YES if the pool was emptied, NO otherwise.
/** Waits until the pool of operations is empty (and idle) or until the
* specified timestamp. Returns YES if the pool was emptied, NO otherwise.
*/
- (BOOL) drain: (NSDate*)before;
@ -69,7 +69,7 @@
*/
- (NSUInteger) flush;
/** Returns humnan resdable pool statistics.
/** Returns human resdable pool statistics.
*/
- (NSString*) info;

View file

@ -133,7 +133,7 @@ static GSThreadPool *shared = nil;
- (BOOL) drain: (NSDate*)before
{
BOOL result = [self isEmpty];
BOOL result = ([self isEmpty] && [self isIdle]) ? YES : NO;
while (NO == result && [before timeIntervalSinceNow] > 0.0)
{
@ -146,7 +146,7 @@ static GSThreadPool *shared = nil;
#else
[NSThread sleepForTimeInterval: 0.1];
#endif
result = [self isEmpty];
result = ([self isEmpty] && [self isIdle]) ? YES : NO;
}
return result;
}