mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +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))
|
||||
|
||||
#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_ */
|
||||
|
|
|
@ -94,7 +94,13 @@ GS_EXPORT NSString* const NSConnectionProxyCount; /* Objects received */
|
|||
*/
|
||||
@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;
|
||||
|
|
|
@ -49,7 +49,13 @@ typedef NSInteger NSOperationQueuePriority;
|
|||
|
||||
@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 />
|
||||
|
@ -187,9 +193,12 @@ enum {
|
|||
|
||||
@interface NSOperationQueue : NSObject
|
||||
{
|
||||
#if GS_EXPOSE(NSOperationQueue)
|
||||
@private
|
||||
id _internal;
|
||||
#if GS_NONFRAGILE
|
||||
# if defined(GS_NSOperationQueue_IVARS)
|
||||
@public GS_NSOperationQueue_IVARS
|
||||
# endif
|
||||
#else
|
||||
@private id _internal;
|
||||
#endif
|
||||
}
|
||||
#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
|
||||
* library.
|
||||
*
|
||||
* The public class MUST contain a use of the GS_INTERNAL() macro with the
|
||||
* class name as it's argument.
|
||||
* The public class MUST declare its instance variables using code of the
|
||||
* 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,
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#if !GS_NON_FRAGILE
|
||||
#if !GS_NONFRAGILE
|
||||
|
||||
/* Code for when we don't have non-fragile instance variables
|
||||
*/
|
||||
|
@ -84,7 +91,7 @@ if (_internal != 0) DESTROY(_internal);
|
|||
#undef GSIVar
|
||||
#define GSIVar(X,Y) (((GSInternal*)(X->_internal))->Y)
|
||||
|
||||
#else /* GS_NON_FRAGILE */
|
||||
#else /* GS_NONFRAGILE */
|
||||
|
||||
/* We have support for non-fragile ivars
|
||||
*/
|
||||
|
@ -102,6 +109,6 @@ if (_internal != 0) DESTROY(_internal);
|
|||
#undef GSIVar
|
||||
#define GSIVar(X,Y) ((X)->Y)
|
||||
|
||||
#endif /* GS_NON_FRAGILE */
|
||||
#endif /* GS_NONFRAGILE */
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#import "common.h"
|
||||
|
||||
#import "Foundation/NSLock.h"
|
||||
|
||||
#define GS_NSOperation_IVARS \
|
||||
NSRecursiveLock *lock; \
|
||||
NSConditionLock *cond; \
|
||||
|
@ -57,7 +59,6 @@
|
|||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSKeyValueObserving.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#import "GSPrivate.h"
|
||||
|
@ -556,7 +557,7 @@ static NSOperationQueue *mainQueue = nil;
|
|||
- (void) addOperations: (NSArray *)ops
|
||||
waitUntilFinished: (BOOL)shouldWait
|
||||
{
|
||||
NSUInteger count;
|
||||
NSUInteger total;
|
||||
NSUInteger index;
|
||||
|
||||
if (ops == nil || NO == [ops isKindOfClass: [NSArray class]])
|
||||
|
@ -565,15 +566,15 @@ static NSOperationQueue *mainQueue = nil;
|
|||
format: @"[%@-%@] object is not an NSArray",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
count = [ops count];
|
||||
if (count > 0)
|
||||
total = [ops count];
|
||||
if (total > 0)
|
||||
{
|
||||
BOOL invalidArg = NO;
|
||||
GS_BEGINITEMBUF(buf, count, id)
|
||||
NSUInteger toAdd = count;
|
||||
GS_BEGINITEMBUF(buf, total, id)
|
||||
NSUInteger toAdd = total;
|
||||
|
||||
[ops getObjects: buf];
|
||||
for (index = 0; index < count; index++)
|
||||
for (index = 0; index < total; index++)
|
||||
{
|
||||
NSOperation *op = buf[index];
|
||||
|
||||
|
@ -594,7 +595,7 @@ static NSOperationQueue *mainQueue = nil;
|
|||
[internal->lock lock];
|
||||
[self willChangeValueForKey: @"operationCount"];
|
||||
[self willChangeValueForKey: @"operations"];
|
||||
for (index = 0; index < count; index++)
|
||||
for (index = 0; index < total; index++)
|
||||
{
|
||||
NSOperation *op = buf[index];
|
||||
|
||||
|
@ -621,7 +622,7 @@ static NSOperationQueue *mainQueue = nil;
|
|||
}
|
||||
[self didChangeValueForKey: @"operationCount"];
|
||||
[self didChangeValueForKey: @"operations"];
|
||||
for (index = 0; index < count; index++)
|
||||
for (index = 0; index < total; index++)
|
||||
{
|
||||
NSOperation *op = buf[index];
|
||||
|
||||
|
@ -683,8 +684,6 @@ static NSOperationQueue *mainQueue = nil;
|
|||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (_internal != nil)
|
||||
{
|
||||
[internal->operations release];
|
||||
[internal->waiting release];
|
||||
|
@ -692,7 +691,6 @@ static NSOperationQueue *mainQueue = nil;
|
|||
[internal->cond release];
|
||||
[internal->lock release];
|
||||
GS_DESTROY_INTERNAL(NSOperationQueue);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -1036,13 +1034,13 @@ static NSOperationQueue *mainQueue = nil;
|
|||
&& [self maxConcurrentOperationCount] != 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
|
||||
* number of threads, so we can create a new one for the
|
||||
|
|
Loading…
Reference in a new issue