mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
inon-fragile ivar update
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29780 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
837c59689b
commit
85191c6fc9
5 changed files with 52 additions and 38 deletions
|
@ -206,10 +206,4 @@
|
||||||
|
|
||||||
#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS))
|
#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS))
|
||||||
|
|
||||||
#if GS_NONFRAGILE
|
|
||||||
# define GS_INTERNAL(X) @public GS_##X##_IVARS
|
|
||||||
#else
|
|
||||||
# define GS_INTERNAL(X) @private id _internal;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */
|
#endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */
|
||||||
|
|
|
@ -94,7 +94,13 @@ GS_EXPORT NSString* const NSConnectionProxyCount; /* Objects received */
|
||||||
*/
|
*/
|
||||||
@interface NSConnection : NSObject
|
@interface NSConnection : NSObject
|
||||||
{
|
{
|
||||||
GS_INTERNAL(NSConnection)
|
#if GS_NONFRAGILE
|
||||||
|
# if defined(GS_NSConnection_IVARS)
|
||||||
|
@public GS_NSConnection_IVARS
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
@private id _internal;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray*) allConnections;
|
+ (NSArray*) allConnections;
|
||||||
|
|
|
@ -49,7 +49,13 @@ typedef NSInteger NSOperationQueuePriority;
|
||||||
|
|
||||||
@interface NSOperation : NSObject
|
@interface NSOperation : NSObject
|
||||||
{
|
{
|
||||||
GS_INTERNAL(NSOperation)
|
#if GS_NONFRAGILE
|
||||||
|
# if defined(GS_NSOperation_IVARS)
|
||||||
|
@public GS_NSOperation_IVARS
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
@private id _internal;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds a dependency to the receiver.<br />
|
/** Adds a dependency to the receiver.<br />
|
||||||
|
@ -187,9 +193,12 @@ enum {
|
||||||
|
|
||||||
@interface NSOperationQueue : NSObject
|
@interface NSOperationQueue : NSObject
|
||||||
{
|
{
|
||||||
#if GS_EXPOSE(NSOperationQueue)
|
#if GS_NONFRAGILE
|
||||||
@private
|
# if defined(GS_NSOperationQueue_IVARS)
|
||||||
id _internal;
|
@public GS_NSOperationQueue_IVARS
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
@private id _internal;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if OS_API_VERSION(100600, GS_API_LATEST)
|
#if OS_API_VERSION(100600, GS_API_LATEST)
|
||||||
|
|
|
@ -27,8 +27,15 @@
|
||||||
* their code when the class implementation is changed in new versions of the
|
* their code when the class implementation is changed in new versions of the
|
||||||
* library.
|
* library.
|
||||||
*
|
*
|
||||||
* The public class MUST contain a use of the GS_INTERNAL() macro with the
|
* The public class MUST declare its instance variables using code of the
|
||||||
* class name as it's argument.
|
* form:
|
||||||
|
* #if GS_NONFRAGILE
|
||||||
|
* # if defined(GS_X_IVARS)
|
||||||
|
* @public GS_X_IVARS
|
||||||
|
* # endif
|
||||||
|
* #else
|
||||||
|
* @private id _internal;
|
||||||
|
* #endif
|
||||||
*
|
*
|
||||||
* Before including the header file containing the public class declaration,
|
* Before including the header file containing the public class declaration,
|
||||||
* you must define GS_X_IVARS (where X is the class name) to be the
|
* you must define GS_X_IVARS (where X is the class name) to be the
|
||||||
|
@ -52,7 +59,7 @@
|
||||||
* the GSIV(classname,object,ivar) macro.
|
* the GSIV(classname,object,ivar) macro.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if !GS_NON_FRAGILE
|
#if !GS_NONFRAGILE
|
||||||
|
|
||||||
/* Code for when we don't have non-fragile instance variables
|
/* Code for when we don't have non-fragile instance variables
|
||||||
*/
|
*/
|
||||||
|
@ -84,7 +91,7 @@ if (_internal != 0) DESTROY(_internal);
|
||||||
#undef GSIVar
|
#undef GSIVar
|
||||||
#define GSIVar(X,Y) (((GSInternal*)(X->_internal))->Y)
|
#define GSIVar(X,Y) (((GSInternal*)(X->_internal))->Y)
|
||||||
|
|
||||||
#else /* GS_NON_FRAGILE */
|
#else /* GS_NONFRAGILE */
|
||||||
|
|
||||||
/* We have support for non-fragile ivars
|
/* We have support for non-fragile ivars
|
||||||
*/
|
*/
|
||||||
|
@ -102,6 +109,6 @@ if (_internal != 0) DESTROY(_internal);
|
||||||
#undef GSIVar
|
#undef GSIVar
|
||||||
#define GSIVar(X,Y) ((X)->Y)
|
#define GSIVar(X,Y) ((X)->Y)
|
||||||
|
|
||||||
#endif /* GS_NON_FRAGILE */
|
#endif /* GS_NONFRAGILE */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#import "common.h"
|
#import "common.h"
|
||||||
|
|
||||||
|
#import "Foundation/NSLock.h"
|
||||||
|
|
||||||
#define GS_NSOperation_IVARS \
|
#define GS_NSOperation_IVARS \
|
||||||
NSRecursiveLock *lock; \
|
NSRecursiveLock *lock; \
|
||||||
NSConditionLock *cond; \
|
NSConditionLock *cond; \
|
||||||
|
@ -57,7 +59,6 @@
|
||||||
#import "Foundation/NSDictionary.h"
|
#import "Foundation/NSDictionary.h"
|
||||||
#import "Foundation/NSEnumerator.h"
|
#import "Foundation/NSEnumerator.h"
|
||||||
#import "Foundation/NSException.h"
|
#import "Foundation/NSException.h"
|
||||||
#import "Foundation/NSLock.h"
|
|
||||||
#import "Foundation/NSKeyValueObserving.h"
|
#import "Foundation/NSKeyValueObserving.h"
|
||||||
#import "Foundation/NSThread.h"
|
#import "Foundation/NSThread.h"
|
||||||
#import "GSPrivate.h"
|
#import "GSPrivate.h"
|
||||||
|
@ -556,7 +557,7 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
- (void) addOperations: (NSArray *)ops
|
- (void) addOperations: (NSArray *)ops
|
||||||
waitUntilFinished: (BOOL)shouldWait
|
waitUntilFinished: (BOOL)shouldWait
|
||||||
{
|
{
|
||||||
NSUInteger count;
|
NSUInteger total;
|
||||||
NSUInteger index;
|
NSUInteger index;
|
||||||
|
|
||||||
if (ops == nil || NO == [ops isKindOfClass: [NSArray class]])
|
if (ops == nil || NO == [ops isKindOfClass: [NSArray class]])
|
||||||
|
@ -565,15 +566,15 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
format: @"[%@-%@] object is not an NSArray",
|
format: @"[%@-%@] object is not an NSArray",
|
||||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||||
}
|
}
|
||||||
count = [ops count];
|
total = [ops count];
|
||||||
if (count > 0)
|
if (total > 0)
|
||||||
{
|
{
|
||||||
BOOL invalidArg = NO;
|
BOOL invalidArg = NO;
|
||||||
GS_BEGINITEMBUF(buf, count, id)
|
GS_BEGINITEMBUF(buf, total, id)
|
||||||
NSUInteger toAdd = count;
|
NSUInteger toAdd = total;
|
||||||
|
|
||||||
[ops getObjects: buf];
|
[ops getObjects: buf];
|
||||||
for (index = 0; index < count; index++)
|
for (index = 0; index < total; index++)
|
||||||
{
|
{
|
||||||
NSOperation *op = buf[index];
|
NSOperation *op = buf[index];
|
||||||
|
|
||||||
|
@ -594,7 +595,7 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
[internal->lock lock];
|
[internal->lock lock];
|
||||||
[self willChangeValueForKey: @"operationCount"];
|
[self willChangeValueForKey: @"operationCount"];
|
||||||
[self willChangeValueForKey: @"operations"];
|
[self willChangeValueForKey: @"operations"];
|
||||||
for (index = 0; index < count; index++)
|
for (index = 0; index < total; index++)
|
||||||
{
|
{
|
||||||
NSOperation *op = buf[index];
|
NSOperation *op = buf[index];
|
||||||
|
|
||||||
|
@ -621,7 +622,7 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
}
|
}
|
||||||
[self didChangeValueForKey: @"operationCount"];
|
[self didChangeValueForKey: @"operationCount"];
|
||||||
[self didChangeValueForKey: @"operations"];
|
[self didChangeValueForKey: @"operations"];
|
||||||
for (index = 0; index < count; index++)
|
for (index = 0; index < total; index++)
|
||||||
{
|
{
|
||||||
NSOperation *op = buf[index];
|
NSOperation *op = buf[index];
|
||||||
|
|
||||||
|
@ -684,15 +685,12 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
if (_internal != nil)
|
|
||||||
{
|
|
||||||
[internal->operations release];
|
[internal->operations release];
|
||||||
[internal->waiting release];
|
[internal->waiting release];
|
||||||
[internal->name release];
|
[internal->name release];
|
||||||
[internal->cond release];
|
[internal->cond release];
|
||||||
[internal->lock release];
|
[internal->lock release];
|
||||||
GS_DESTROY_INTERNAL(NSOperationQueue);
|
GS_DESTROY_INTERNAL(NSOperationQueue);
|
||||||
}
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,13 +1034,13 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
&& [self maxConcurrentOperationCount] != 0
|
&& [self maxConcurrentOperationCount] != 0
|
||||||
&& [internal->waiting count] > 0)
|
&& [internal->waiting count] > 0)
|
||||||
{
|
{
|
||||||
NSInteger count = internal->count;
|
NSInteger total = internal->count;
|
||||||
|
|
||||||
if (count == NSOperationQueueDefaultMaxConcurrentOperationCount)
|
if (total == NSOperationQueueDefaultMaxConcurrentOperationCount)
|
||||||
{
|
{
|
||||||
count = maxThreads; // Limit number of allowed threads
|
total = maxThreads; // Limit number of allowed threads
|
||||||
}
|
}
|
||||||
if (internal->threads < count)
|
if (internal->threads < total)
|
||||||
{
|
{
|
||||||
/* All threads are in use, but we don't have the maximum
|
/* All threads are in use, but we don't have the maximum
|
||||||
* number of threads, so we can create a new one for the
|
* number of threads, so we can create a new one for the
|
||||||
|
|
Loading…
Reference in a new issue