mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-21 19:01:32 +00:00
tweaks for older osx versions
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@32441 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
75fb416fc7
commit
01e4d495a4
2 changed files with 45 additions and 4 deletions
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
#import <Foundation/NSObject.h>
|
#import <Foundation/NSObject.h>
|
||||||
|
|
||||||
#if !defined (GNUSTEP) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
|
#if !defined (GNUSTEP) && (MAC_OS_X_VERSION_MAX_ALLOWED<=MAC_OS_X_VERSION_10_4)
|
||||||
typedef unsigned int NSUInteger;
|
typedef unsigned int NSUInteger;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,15 @@ static GSThreadPool *shared = nil;
|
||||||
|
|
||||||
while (NO == result && [before timeIntervalSinceNow] > 0.0)
|
while (NO == result && [before timeIntervalSinceNow] > 0.0)
|
||||||
{
|
{
|
||||||
|
#if !defined (GNUSTEP) && (MAC_OS_X_VERSION_MAX_ALLOWED<=MAC_OS_X_VERSION_10_4)
|
||||||
|
NSDate *when;
|
||||||
|
|
||||||
|
when = [NSDate alloc] initWithTimeIntervalSinceNow: 0.1];
|
||||||
|
[NSThread sleepUntilDate: when];
|
||||||
|
[when release];
|
||||||
|
#else
|
||||||
[NSThread sleepForTimeInterval: 0.1];
|
[NSThread sleepForTimeInterval: 0.1];
|
||||||
|
#endif
|
||||||
result = [self isEmpty];
|
result = [self isEmpty];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -334,17 +342,42 @@ static GSThreadPool *shared = nil;
|
||||||
NSThread *thread;
|
NSThread *thread;
|
||||||
|
|
||||||
/* Create a new link, add it to the idle list, and start the
|
/* Create a new link, add it to the idle list, and start the
|
||||||
* thread which will work withn it.
|
* thread which will work with it.
|
||||||
*/
|
*/
|
||||||
link = [GSThreadLink new];
|
link = [GSThreadLink new];
|
||||||
link->pool = self;
|
link->pool = self;
|
||||||
|
GSLinkedListInsertAfter(link, idle, idle->tail);
|
||||||
|
|
||||||
|
#if !defined (GNUSTEP) && (MAC_OS_X_VERSION_MAX_ALLOWED<=MAC_OS_X_VERSION_10_4)
|
||||||
|
|
||||||
|
/* With the old thread API we can't get an NSThread object
|
||||||
|
* until after the thread has started ... so we start the
|
||||||
|
* thread and then wait for the new thread to have set the
|
||||||
|
* link item up properly.
|
||||||
|
*/
|
||||||
|
[NSThread detachNewThreadSelector: @selector(_run:)
|
||||||
|
toTarget: self
|
||||||
|
withObject: link];
|
||||||
|
while (nil == link->item)
|
||||||
|
{
|
||||||
|
NSDate *when;
|
||||||
|
|
||||||
|
when = [[NSDate alloc]
|
||||||
|
initWithTimeIntervalSinceNow: 0.001];
|
||||||
|
[NSThread sleepUntilDate: when];
|
||||||
|
[when release];
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* New thread API ... create thread object, set it in the
|
||||||
|
* link, then start the thread.
|
||||||
|
*/
|
||||||
thread = [[NSThread alloc] initWithTarget: self
|
thread = [[NSThread alloc] initWithTarget: self
|
||||||
selector: @selector(_run:)
|
selector: @selector(_run:)
|
||||||
object: link];
|
object: link];
|
||||||
[link setItem: thread];
|
[link setItem: thread];
|
||||||
[thread release]; // Retained by link
|
|
||||||
GSLinkedListInsertAfter(link, idle, idle->tail);
|
|
||||||
[thread start];
|
[thread start];
|
||||||
|
[thread release]; // Retained by link
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -434,6 +467,14 @@ static GSThreadPool *shared = nil;
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *arp;
|
NSAutoreleasePool *arp;
|
||||||
|
|
||||||
|
#if !defined (GNUSTEP) && (MAC_OS_X_VERSION_MAX_ALLOWED<=MAC_OS_X_VERSION_10_4)
|
||||||
|
/* With the older thread API we must set up the link item *after* the
|
||||||
|
* thread starts. With the new API this is not needed as we cans set
|
||||||
|
* things up and then start the thread.
|
||||||
|
*/
|
||||||
|
[link setItem: [NSThread currentThread]];
|
||||||
|
#endif
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
GSOperation *op;
|
GSOperation *op;
|
||||||
|
|
Loading…
Reference in a new issue