mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-21 04:32:03 +00:00
Thread fixes for NSConnection
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8174 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d84f89cc45
commit
6c5c018c86
6 changed files with 29 additions and 14 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,4 +1,18 @@
|
||||||
2000-11-18 Richard Frith-Macdonald <rfm@gnu.org>
|
2000-11-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Headers/gnustep/base/NSAutoreleasePool.h: Changed proivate method
|
||||||
|
for cleanup at end of thread.
|
||||||
|
* Headers/gnustep/base/NSThead.h: New ivar to mark when we are
|
||||||
|
deallocating.
|
||||||
|
* Source/NSAutoreleasePool.m: Added parameter to _endThread so we
|
||||||
|
can safely end a thread without it being the current one.
|
||||||
|
* Source/NSThread.m: Now clean up autorelease pools *after*
|
||||||
|
everything elese, while deallocating the thread. This is to cope
|
||||||
|
with objects that try to access the thread dictionary while
|
||||||
|
autoreleasing. -threadDictionary modified to return nil during
|
||||||
|
deallocation rather than creating a new ductionary.
|
||||||
|
|
||||||
|
2000-11-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/externs.m: Removed obsolete http body key.
|
* Source/externs.m: Removed obsolete http body key.
|
||||||
* Source/GSHTTPURLHandle.m: Removed obsolete http body key.
|
* Source/GSHTTPURLHandle.m: Removed obsolete http body key.
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <Foundation/NSObject.h>
|
#include <Foundation/NSObject.h>
|
||||||
|
|
||||||
@class NSAutoreleasePool;
|
@class NSAutoreleasePool;
|
||||||
|
@class NSThread;
|
||||||
|
|
||||||
|
|
||||||
/* Each thread has its own copy of these variables.
|
/* Each thread has its own copy of these variables.
|
||||||
|
@ -91,7 +92,7 @@ struct autorelease_array_list
|
||||||
+ (void) enableRelease: (BOOL)enable;
|
+ (void) enableRelease: (BOOL)enable;
|
||||||
+ (void) setPoolCountThreshhold: (unsigned)c;
|
+ (void) setPoolCountThreshhold: (unsigned)c;
|
||||||
+ (unsigned) autoreleaseCountForObject: (id)anObject;
|
+ (unsigned) autoreleaseCountForObject: (id)anObject;
|
||||||
+ (void) _endThread; /* Don't call this directly - NSThread uses it. */
|
+ (void) _endThread: (NSThread*)thread; /* Don't call this directly. */
|
||||||
/*
|
/*
|
||||||
* The next two methods have no effect unless you define COUNT_ALL to be
|
* The next two methods have no effect unless you define COUNT_ALL to be
|
||||||
* 1 in NSAutoreleasepool.m - doing so incurs a thread lookup overhead
|
* 1 in NSAutoreleasepool.m - doing so incurs a thread lookup overhead
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef enum
|
||||||
id _arg;
|
id _arg;
|
||||||
SEL _selector;
|
SEL _selector;
|
||||||
BOOL _active;
|
BOOL _active;
|
||||||
|
BOOL _deallocating;
|
||||||
@public
|
@public
|
||||||
NSHandler *_exception_handler;
|
NSHandler *_exception_handler;
|
||||||
NSMutableDictionary *_thread_dictionary;
|
NSMutableDictionary *_thread_dictionary;
|
||||||
|
|
|
@ -1552,6 +1552,7 @@ static Class tcpPortClass;
|
||||||
|
|
||||||
- (void) gcFinalize
|
- (void) gcFinalize
|
||||||
{
|
{
|
||||||
|
NSDebugMLLog(@"NSPort", @"GSTcpPort 0x%x finalized", self);
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -390,12 +390,12 @@ static IMP initImp;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) _endThread
|
+ (void) _endThread: (NSThread*)thread
|
||||||
{
|
{
|
||||||
struct autorelease_thread_vars *tv;
|
struct autorelease_thread_vars *tv;
|
||||||
id pool;
|
id pool;
|
||||||
|
|
||||||
tv = ARP_THREAD_VARS;
|
tv = &(GSCurrentThread()->_autorelease_vars);
|
||||||
while (tv->current_pool)
|
while (tv->current_pool)
|
||||||
{
|
{
|
||||||
[tv->current_pool release];
|
[tv->current_pool release];
|
||||||
|
|
|
@ -226,16 +226,13 @@ gnustep_base_thread_callback()
|
||||||
[[NSNotificationCenter defaultCenter] postNotification: n];
|
[[NSNotificationCenter defaultCenter] postNotification: n];
|
||||||
RELEASE(n);
|
RELEASE(n);
|
||||||
|
|
||||||
/*
|
|
||||||
* Release anything in our autorelease pools
|
|
||||||
*/
|
|
||||||
[NSAutoreleasePool _endThread];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* destroy the thread object.
|
* destroy the thread object.
|
||||||
*/
|
*/
|
||||||
DESTROY(t);
|
DESTROY(t);
|
||||||
|
|
||||||
|
objc_thread_set_data (NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tell the runtime to exit the thread
|
* Tell the runtime to exit the thread
|
||||||
*/
|
*/
|
||||||
|
@ -332,9 +329,12 @@ gnustep_base_thread_callback()
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Deallocating an active thread without [+exit]!"];
|
format: @"Deallocating an active thread without [+exit]!"];
|
||||||
}
|
}
|
||||||
|
_deallocating = YES;
|
||||||
DESTROY(_thread_dictionary);
|
DESTROY(_thread_dictionary);
|
||||||
DESTROY(_target);
|
DESTROY(_target);
|
||||||
DESTROY(_arg);
|
DESTROY(_arg);
|
||||||
|
[NSAutoreleasePool _endThread: self];
|
||||||
|
|
||||||
NSDeallocateObject(self);
|
NSDeallocateObject(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ gnustep_base_thread_callback()
|
||||||
*/
|
*/
|
||||||
- (NSMutableDictionary*) threadDictionary
|
- (NSMutableDictionary*) threadDictionary
|
||||||
{
|
{
|
||||||
if (_thread_dictionary == nil)
|
if (_thread_dictionary == nil && _deallocating == NO)
|
||||||
{
|
{
|
||||||
_thread_dictionary = [NSMutableDictionary new];
|
_thread_dictionary = [NSMutableDictionary new];
|
||||||
}
|
}
|
||||||
|
@ -450,14 +450,12 @@ gnustep_base_thread_callback()
|
||||||
* Set the thread to be inactive to avoid any possibility of recursion.
|
* Set the thread to be inactive to avoid any possibility of recursion.
|
||||||
*/
|
*/
|
||||||
thread->_active = NO;
|
thread->_active = NO;
|
||||||
/*
|
|
||||||
* Release anything in our autorelease pools
|
|
||||||
*/
|
|
||||||
[NSAutoreleasePool _endThread];
|
|
||||||
/*
|
/*
|
||||||
* destroy the thread object.
|
* destroy the thread object.
|
||||||
*/
|
*/
|
||||||
DESTROY (thread);
|
DESTROY (thread);
|
||||||
|
|
||||||
objc_thread_set_data (NULL);
|
objc_thread_set_data (NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue