mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-21 02:41:01 +00:00
add shared pool
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@31457 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e3812b5651
commit
d3ea09ddac
3 changed files with 37 additions and 2 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,10 +1,16 @@
|
||||||
|
2010-10-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* GSThreadPool.h:
|
||||||
|
* GSThreadPool.m:
|
||||||
|
Add new methed to return a shared pool.
|
||||||
|
|
||||||
2010-09-29 Richard Frith-Macdonald <rfm@gnu.org>
|
2010-09-29 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* GSLinkedList.h:
|
* GSLinkedList.h:
|
||||||
* GSLinkedList.m:
|
* GSLinkedList.m:
|
||||||
Revise structure and API for greater flexibility.
|
Revise structure and API for greater flexibility.
|
||||||
* GSThreadPool.h
|
* GSThreadPool.h:
|
||||||
* GSThreadPool.m
|
* GSThreadPool.m:
|
||||||
Modify for new linked list api.
|
Modify for new linked list api.
|
||||||
|
|
||||||
2010-09-23 Richard Frith-Macdonald <rfm@gnu.org>
|
2010-09-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
|
@ -48,6 +48,14 @@
|
||||||
NSUInteger processed;
|
NSUInteger processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns an instance intended for sharing between sections of code which
|
||||||
|
* wish to make use of threading by performing operations in other threads,
|
||||||
|
* but which don't mind operations being interleaved with those belonging to
|
||||||
|
* oither sections of code.<br />
|
||||||
|
* Always returns the same instance whenever the method is called.
|
||||||
|
*/
|
||||||
|
+ (GSThreadPool*) sharedPool;
|
||||||
|
|
||||||
/** Waits until the pool of operations is empty or until the specified
|
/** Waits until the pool of operations is empty or until the specified
|
||||||
* timestamp. Returns YES if the pool was emptied, NO otherwise.
|
* timestamp. Returns YES if the pool was emptied, NO otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -57,10 +57,31 @@
|
||||||
|
|
||||||
@implementation GSThreadPool
|
@implementation GSThreadPool
|
||||||
|
|
||||||
|
static GSThreadPool *shared = nil;
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
if ([GSThreadPool class] == self)
|
||||||
|
{
|
||||||
|
shared = [self new];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (GSThreadPool*) sharedPool
|
||||||
|
{
|
||||||
|
return shared;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
GSThreadLink *link;
|
GSThreadLink *link;
|
||||||
|
|
||||||
|
if (self == shared)
|
||||||
|
{
|
||||||
|
[self retain];
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"[GSThreadPool-dealloc] attempt to deallocate shared pool"];
|
||||||
|
}
|
||||||
[poolLock lock];
|
[poolLock lock];
|
||||||
[operations release];
|
[operations release];
|
||||||
operations = nil;
|
operations = nil;
|
||||||
|
|
Loading…
Reference in a new issue