mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-21 10:51:15 +00:00
hacks for old system
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@32446 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2e05fded5f
commit
225cf05f9e
2 changed files with 16 additions and 3 deletions
|
@ -36,7 +36,10 @@ typedef unsigned int NSUInteger;
|
||||||
* Operations are performed on these threads using the standard
|
* Operations are performed on these threads using the standard
|
||||||
* -performSelector:onThread:withObject:waitUntilDone: method ... the
|
* -performSelector:onThread:withObject:waitUntilDone: method ... the
|
||||||
* pool is simply used to keep track of allocation of threads so that
|
* pool is simply used to keep track of allocation of threads so that
|
||||||
* you can share jobs between them.
|
* you can share jobs between them.<br />
|
||||||
|
* NB. The threading API in OSX 10.4 and earlier is incapable of supporting
|
||||||
|
* this functionality ... in that case this class cannot be instantiated
|
||||||
|
* and initialised.
|
||||||
*/
|
*/
|
||||||
@interface GSIOThreadPool : NSObject
|
@interface GSIOThreadPool : NSObject
|
||||||
{
|
{
|
||||||
|
@ -54,7 +57,7 @@ typedef unsigned int NSUInteger;
|
||||||
*/
|
*/
|
||||||
+ (GSIOThreadPool*) sharedPool;
|
+ (GSIOThreadPool*) sharedPool;
|
||||||
|
|
||||||
/** Seects a thread from the pool to be used for some job.
|
/** Selects a thread from the pool to be used for some job.
|
||||||
*/
|
*/
|
||||||
- (NSThread*) acquireThread;
|
- (NSThread*) acquireThread;
|
||||||
|
|
||||||
|
@ -68,7 +71,7 @@ typedef unsigned int NSUInteger;
|
||||||
|
|
||||||
/** Specify the maximum number of threads in the pool (the actual number
|
/** Specify the maximum number of threads in the pool (the actual number
|
||||||
* used may be lower than this value).<br />
|
* used may be lower than this value).<br />
|
||||||
* Default is 2.<br />
|
* Default is 0 (no thread pooling in use).<br />
|
||||||
* The pool creates threads on demand up to the specified limit (or a lower
|
* The pool creates threads on demand up to the specified limit (or a lower
|
||||||
* limit if dictated by system resources) but will not destroy idle threads
|
* limit if dictated by system resources) but will not destroy idle threads
|
||||||
* unless the limit is subsequently lowered.<br />
|
* unless the limit is subsequently lowered.<br />
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
[NSThread exit];
|
[NSThread exit];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(GNUSTEP) || (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [super initWithTarget: self selector: @selector(run) object: nil];
|
self = [super initWithTarget: self selector: @selector(run) object: nil];
|
||||||
|
@ -59,6 +60,7 @@
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Run the thread's main runloop until terminated.
|
/* Run the thread's main runloop until terminated.
|
||||||
*/
|
*/
|
||||||
|
@ -170,6 +172,7 @@ best(NSMutableArray *a)
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
#if defined(GNUSTEP) || (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
|
||||||
GSIOThread *thread;
|
GSIOThread *thread;
|
||||||
NSDate *when = [NSDate dateWithTimeIntervalSinceNow: timeout];
|
NSDate *when = [NSDate dateWithTimeIntervalSinceNow: timeout];
|
||||||
|
|
||||||
|
@ -185,16 +188,23 @@ best(NSMutableArray *a)
|
||||||
[threads release];
|
[threads release];
|
||||||
[poolLock unlock];
|
[poolLock unlock];
|
||||||
[poolLock release];
|
[poolLock release];
|
||||||
|
#endif
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
|
#if defined(GNUSTEP) || (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
|
||||||
if ((self = [super init]) != nil)
|
if ((self = [super init]) != nil)
|
||||||
{
|
{
|
||||||
poolLock = [NSLock new];
|
poolLock = [NSLock new];
|
||||||
threads = [NSMutableArray new];
|
threads = [NSMutableArray new];
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
[self release];
|
||||||
|
NSLog(@"WARNING, your OSX system is too old to use GSIOthreadPool");
|
||||||
|
return nil;
|
||||||
|
#endif
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue