mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-23 20:01:15 +00:00
add some diagnostics
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@31400 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
431f3efb80
commit
0c664e3100
3 changed files with 48 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
2010-09-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* performance/GSThreadPool.h:
|
||||
* performance/GSThreadPool.m:
|
||||
Track count of active threads and count of number of methods
|
||||
performed in the thread pool. Display via -description.
|
||||
|
||||
2010-09-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* GSLinkedList.h:
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
BOOL suspended;
|
||||
NSUInteger maxThreads;
|
||||
NSUInteger threadCount;
|
||||
NSUInteger activeCount;
|
||||
GSThreadLink *idle;
|
||||
GSThreadLink *live;
|
||||
NSUInteger maxOperations;
|
||||
|
@ -50,6 +51,7 @@
|
|||
GSOperation *lastOperation;
|
||||
NSUInteger unusedCount;
|
||||
GSOperation *unused;
|
||||
NSUInteger processed;
|
||||
}
|
||||
|
||||
/** Waits until the pool of operations is empty or until the specified
|
||||
|
@ -91,7 +93,10 @@
|
|||
* You may add an object more than once, but that may result in the operation
|
||||
* being performed simultaneously in more than one thread.<br />
|
||||
* If the pool is configured with zero threads or zero operations,
|
||||
* this method will simply perform the operation immediately.
|
||||
* this method will simply perform the operation immediately.<br />
|
||||
* The operation will be performed in a context where there is an exception
|
||||
* handler set to trap exceptions, and an autorelease pool to deal with
|
||||
* autoreleased objects.
|
||||
*/
|
||||
- (void) scheduleSelector: (SEL)aSelector
|
||||
onReceiver: (NSObject*)aReceiver
|
||||
|
|
|
@ -93,6 +93,19 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString*) description
|
||||
{
|
||||
NSString *result;
|
||||
|
||||
[poolLock lock];
|
||||
result = [NSString stringWithFormat:
|
||||
@"%@ queue: %u(%u) threads: %u(%u) active: %u processed: %u",
|
||||
[super description], operationCount, maxOperations,
|
||||
threadCount, maxThreads, activeCount, processed];
|
||||
[poolLock unlock];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL) drain: (NSDate*)before
|
||||
{
|
||||
BOOL result = [self isEmpty];
|
||||
|
@ -220,8 +233,26 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
NSAutoreleasePool *arp;
|
||||
|
||||
[poolLock unlock];
|
||||
[aReceiver performSelector: aSelector withObject: anArgument];
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
arp = [NSAutoreleasePool new];
|
||||
[aReceiver performSelector: aSelector withObject: anArgument];
|
||||
[arp release];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
arp = [NSAutoreleasePool new];
|
||||
NSLog(@"[%@-%@] %@",
|
||||
NSStringFromClass([aReceiver class]),
|
||||
NSStringFromSelector(aSelector),
|
||||
localException);
|
||||
[arp release];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,6 +353,7 @@
|
|||
idle = [link remove];
|
||||
[live insert: link];
|
||||
live = link;
|
||||
activeCount++;
|
||||
link->op = op;
|
||||
[link->lock lock];
|
||||
[link->lock unlockWithCondition: 1];
|
||||
|
@ -379,6 +411,7 @@
|
|||
{
|
||||
[link remove];
|
||||
}
|
||||
activeCount--;
|
||||
if (threadCount > maxThreads)
|
||||
{
|
||||
threadCount--;
|
||||
|
@ -403,6 +436,7 @@
|
|||
BOOL more = NO;
|
||||
|
||||
[poolLock lock];
|
||||
processed++;
|
||||
if (unusedCount < maxOperations)
|
||||
{
|
||||
if (nil != op->arg)
|
||||
|
|
Loading…
Reference in a new issue