diff --git a/ChangeLog b/ChangeLog index af8855183..4d4642b45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,8 +7,9 @@ * Source/NSThread.m (GSRegisterCurrentThread): Call objc_thread_add before creating the NSThread object using a method - call. - + call. (GSUnregisterCurrentThread): Post the NSThreadWillExit + notification. + 2001-03-19 Jonathan Gapen * Source/NSString.m: In ([-rangeOfComposedCharacterSequenceAtIndex:]), diff --git a/Headers/gnustep/base/NSThread.h b/Headers/gnustep/base/NSThread.h index c07e9de3b..4b0364f68 100644 --- a/Headers/gnustep/base/NSThread.h +++ b/Headers/gnustep/base/NSThread.h @@ -93,7 +93,8 @@ GS_EXPORT BOOL GSRegisterCurrentThread (void); * registerCurrentThread (). This method is basically the same as * `+exit', but does not exit the thread - just destroys all objects * associated with the thread. Warning: using any GNUstep code after - * this method call is not safe. */ + * this method call is not safe. Posts an NSThreadWillExit + * notification. x*/ GS_EXPORT void GSUnregisterCurrentThread (void); #endif diff --git a/Source/NSThread.m b/Source/NSThread.m index 8435bb091..b1a1be7f2 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -475,15 +475,35 @@ void GSUnregisterCurrentThread (void) { NSThread *thread; + static NSNotificationCenter *nc = nil; + static Class notificationClass = Nil; + if (nc == nil) + { + nc = [NSNotificationCenter defaultCenter]; + notificationClass = [NSNotification class]; + } + thread = GSCurrentThread(); if (thread->_active == YES) { + NSNotification *n; + /* * Set the thread to be inactive to avoid any possibility of recursion. */ thread->_active = NO; + + /* + * Let observers know this thread is exiting. + */ + n = [notificationClass alloc]; + n = [n initWithName: NSThreadWillExitNotification + object: thread + userInfo: nil]; + [nc postNotification: n]; + RELEASE(n); /* * destroy the thread object.