Minor thread tidyup

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20155 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-09-27 08:59:04 +00:00
parent 485e7f8ece
commit 61fade5ef4
2 changed files with 11 additions and 6 deletions

View file

@ -2,6 +2,9 @@
* Source/NSDebug.m: Remove checks for existence of lock ... it always * Source/NSDebug.m: Remove checks for existence of lock ... it always
exists, so the checks are useless. exists, so the checks are useless.
* Source/NSThread.m: Refrain from creating thread dictionary in an
inactive thread ... we don't want to create new objects in a thread
which is in the process of exiting.
2004-09-24 Richard Frith-Macdonald <rfm@gnu.org> 2004-09-24 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -53,6 +53,8 @@
@class GSPerformHolder; @class GSPerformHolder;
typedef struct { @defs(NSThread) } NSThread_ivars;
static Class threadClass = Nil; static Class threadClass = Nil;
static NSNotificationCenter *nc = nil; static NSNotificationCenter *nc = nil;
@ -261,7 +263,8 @@ GSCurrentThread(void)
} }
/** /**
* Fast access function for thread dictionary of current thread. * Fast access function for thread dictionary of current thread.<br />
* If there is no dictionary, and the thread is active, creates the dictionary.
*/ */
NSMutableDictionary* NSMutableDictionary*
GSDictionaryForThread(NSThread *t) GSDictionaryForThread(NSThread *t)
@ -278,7 +281,7 @@ GSDictionaryForThread(NSThread *t)
{ {
NSMutableDictionary *dict = t->_thread_dictionary; NSMutableDictionary *dict = t->_thread_dictionary;
if (dict == nil) if (dict == nil && ((NSThread_ivars *)t)->_active == YES)
{ {
dict = [t threadDictionary]; dict = [t threadDictionary];
} }
@ -313,7 +316,9 @@ NSTimer *GSHousekeeper(void)
/** /**
* Returns the runloop for the specified thread (or, if t is nil, * Returns the runloop for the specified thread (or, if t is nil,
* for the current thread). Creates a new runloop if necessary.<br /> * for the current thread).<br />
* Creates a new runloop if necessary,
* as long as the thread dictionary exists.<br />
* Returns nil on failure. * Returns nil on failure.
*/ */
NSRunLoop* NSRunLoop*
@ -1066,9 +1071,6 @@ static NSDate *theFuture;
} }
@end @end
typedef struct { @defs(NSThread) } NSThread_ivars;
/** /**
* <p> * <p>
* This function is provided to let threads started by some other * This function is provided to let threads started by some other