mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +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
4211a9d8dd
commit
472f5a6d1f
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/GSHTTPURLHandle.m: Removed obsolete http body key.
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <Foundation/NSObject.h>
|
||||
|
||||
@class NSAutoreleasePool;
|
||||
@class NSThread;
|
||||
|
||||
|
||||
/* Each thread has its own copy of these variables.
|
||||
|
@ -91,7 +92,7 @@ struct autorelease_array_list
|
|||
+ (void) enableRelease: (BOOL)enable;
|
||||
+ (void) setPoolCountThreshhold: (unsigned)c;
|
||||
+ (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
|
||||
* 1 in NSAutoreleasepool.m - doing so incurs a thread lookup overhead
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef enum
|
|||
id _arg;
|
||||
SEL _selector;
|
||||
BOOL _active;
|
||||
BOOL _deallocating;
|
||||
@public
|
||||
NSHandler *_exception_handler;
|
||||
NSMutableDictionary *_thread_dictionary;
|
||||
|
|
|
@ -1552,6 +1552,7 @@ static Class tcpPortClass;
|
|||
|
||||
- (void) gcFinalize
|
||||
{
|
||||
NSDebugMLLog(@"NSPort", @"GSTcpPort 0x%x finalized", self);
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
|
|
|
@ -390,12 +390,12 @@ static IMP initImp;
|
|||
return self;
|
||||
}
|
||||
|
||||
+ (void) _endThread
|
||||
+ (void) _endThread: (NSThread*)thread
|
||||
{
|
||||
struct autorelease_thread_vars *tv;
|
||||
id pool;
|
||||
|
||||
tv = ARP_THREAD_VARS;
|
||||
tv = &(GSCurrentThread()->_autorelease_vars);
|
||||
while (tv->current_pool)
|
||||
{
|
||||
[tv->current_pool release];
|
||||
|
|
|
@ -226,16 +226,13 @@ gnustep_base_thread_callback()
|
|||
[[NSNotificationCenter defaultCenter] postNotification: n];
|
||||
RELEASE(n);
|
||||
|
||||
/*
|
||||
* Release anything in our autorelease pools
|
||||
*/
|
||||
[NSAutoreleasePool _endThread];
|
||||
|
||||
/*
|
||||
* destroy the thread object.
|
||||
*/
|
||||
DESTROY(t);
|
||||
|
||||
objc_thread_set_data (NULL);
|
||||
|
||||
/*
|
||||
* Tell the runtime to exit the thread
|
||||
*/
|
||||
|
@ -332,9 +329,12 @@ gnustep_base_thread_callback()
|
|||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Deallocating an active thread without [+exit]!"];
|
||||
}
|
||||
_deallocating = YES;
|
||||
DESTROY(_thread_dictionary);
|
||||
DESTROY(_target);
|
||||
DESTROY(_arg);
|
||||
[NSAutoreleasePool _endThread: self];
|
||||
|
||||
NSDeallocateObject(self);
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ gnustep_base_thread_callback()
|
|||
*/
|
||||
- (NSMutableDictionary*) threadDictionary
|
||||
{
|
||||
if (_thread_dictionary == nil)
|
||||
if (_thread_dictionary == nil && _deallocating == NO)
|
||||
{
|
||||
_thread_dictionary = [NSMutableDictionary new];
|
||||
}
|
||||
|
@ -450,14 +450,12 @@ gnustep_base_thread_callback()
|
|||
* Set the thread to be inactive to avoid any possibility of recursion.
|
||||
*/
|
||||
thread->_active = NO;
|
||||
/*
|
||||
* Release anything in our autorelease pools
|
||||
*/
|
||||
[NSAutoreleasePool _endThread];
|
||||
|
||||
/*
|
||||
* destroy the thread object.
|
||||
*/
|
||||
DESTROY (thread);
|
||||
|
||||
objc_thread_set_data (NULL);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue