Disable port coder caching by default.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10117 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-06-08 14:04:20 +00:00
parent 5ee5cd8963
commit 15c9f821b0
2 changed files with 35 additions and 18 deletions

View file

@ -1,3 +1,8 @@
2001-06-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSConnection.m: Control caching of port coders by a simple
boolean, and disable it by default.
2001-06-07 Adam Fedor <fedor@gnu.org> 2001-06-07 Adam Fedor <fedor@gnu.org>
* aclocal.m4: Add special case for cygwin in CON_AUTOLOAD. * aclocal.m4: Add special case for cygwin in CON_AUTOLOAD.

View file

@ -249,6 +249,7 @@ static unsigned local_object_counter = 0;
/* class defaults */ /* class defaults */
static NSTimer *timer; static NSTimer *timer;
static BOOL cacheCoders = NO;
static int debug_connection = 0; static int debug_connection = 0;
static NSHashTable *connection_table; static NSHashTable *connection_table;
@ -748,8 +749,11 @@ static BOOL multi_threaded = NO;
/* /*
* These arrays cache NSPortCoder objects * These arrays cache NSPortCoder objects
*/ */
_cachedDecoders = [NSMutableArray new]; if (cacheCoders == YES)
_cachedEncoders = [NSMutableArray new]; {
_cachedDecoders = [NSMutableArray new];
_cachedEncoders = [NSMutableArray new];
}
/* /*
* This is used to queue up incoming NSPortMessages representing requests * This is used to queue up incoming NSPortMessages representing requests
@ -2432,7 +2436,10 @@ static BOOL multi_threaded = NO;
{ {
NSLog(@"done rmc 0x%x", c); NSLog(@"done rmc 0x%x", c);
} }
[_cachedDecoders addObject: c]; if (cacheCoders == YES && _cachedDecoders != nil)
{
[_cachedDecoders addObject: c];
}
[c dispatch]; /* Tell NSPortCoder to release the connection. */ [c dispatch]; /* Tell NSPortCoder to release the connection. */
RELEASE(c); RELEASE(c);
M_UNLOCK(_refGate); M_UNLOCK(_refGate);
@ -2445,16 +2452,17 @@ static BOOL multi_threaded = NO;
- (void) _failInRmc: (NSPortCoder*)c - (void) _failInRmc: (NSPortCoder*)c
{ {
M_LOCK(_refGate); M_LOCK(_refGate);
if ([_cachedDecoders indexOfObjectIdenticalTo: c] == NSNotFound) if (cacheCoders == YES && _cachedDecoders != nil
&& [_cachedDecoders indexOfObjectIdenticalTo: c] == NSNotFound)
{ {
if (debug_connection > 5)
{
NSLog(@"fail rmc 0x%x", c);
}
[_cachedDecoders addObject: c]; [_cachedDecoders addObject: c];
[c dispatch]; /* Tell NSPortCoder to release the connection. */
RELEASE(c);
} }
if (debug_connection > 5)
{
NSLog(@"fail rmc 0x%x", c);
}
[c dispatch]; /* Tell NSPortCoder to release the connection. */
RELEASE(c);
M_UNLOCK(_refGate); M_UNLOCK(_refGate);
} }
@ -2465,12 +2473,13 @@ static BOOL multi_threaded = NO;
- (void) _failOutRmc: (NSPortCoder*)c - (void) _failOutRmc: (NSPortCoder*)c
{ {
M_LOCK(_refGate); M_LOCK(_refGate);
if ([_cachedEncoders indexOfObjectIdenticalTo: c] == NSNotFound) if (cacheCoders == YES && _cachedEncoders != nil
&& [_cachedEncoders indexOfObjectIdenticalTo: c] == NSNotFound)
{ {
[_cachedEncoders addObject: c]; [_cachedEncoders addObject: c];
[c dispatch]; /* Tell NSPortCoder to release the connection. */
RELEASE(c);
} }
[c dispatch]; /* Tell NSPortCoder to release the connection. */
RELEASE(c);
M_UNLOCK(_refGate); M_UNLOCK(_refGate);
} }
@ -2482,8 +2491,8 @@ static BOOL multi_threaded = NO;
NSParameterAssert(_isValid); NSParameterAssert(_isValid);
M_LOCK(_refGate); M_LOCK(_refGate);
count = [_cachedDecoders count]; if (cacheCoders == YES && _cachedDecoders != nil
if (count > 0) && (count = [_cachedDecoders count]) > 0)
{ {
coder = [_cachedDecoders objectAtIndex: --count]; coder = [_cachedDecoders objectAtIndex: --count];
RETAIN(coder); RETAIN(coder);
@ -2536,8 +2545,8 @@ static BOOL multi_threaded = NO;
/* /*
* Locate or create an rmc * Locate or create an rmc
*/ */
count = [_cachedEncoders count]; if (cacheCoders == YES && _cachedEncoders != nil
if (count > 0) && (count = [_cachedEncoders count]) > 0)
{ {
coder = [_cachedEncoders objectAtIndex: --count]; coder = [_cachedEncoders objectAtIndex: --count];
RETAIN(coder); RETAIN(coder);
@ -2632,7 +2641,10 @@ static BOOL multi_threaded = NO;
* We replace the code we have just used in the cache, and tell it not to * We replace the code we have just used in the cache, and tell it not to
* retain this connection any more. * retain this connection any more.
*/ */
[_cachedEncoders addObject: c]; if (cacheCoders == YES && _cachedEncoders != nil)
{
[_cachedEncoders addObject: c];
}
[c dispatch]; /* Tell NSPortCoder to release the connection. */ [c dispatch]; /* Tell NSPortCoder to release the connection. */
RELEASE(c); RELEASE(c);
M_UNLOCK(_refGate); M_UNLOCK(_refGate);