mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 16:50:42 +00:00
Post the NSThreadWillExit notification when unregistering alien threads
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9450 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8dfbba6d5a
commit
6852355af1
3 changed files with 25 additions and 3 deletions
|
@ -7,8 +7,9 @@
|
||||||
|
|
||||||
* Source/NSThread.m (GSRegisterCurrentThread): Call
|
* Source/NSThread.m (GSRegisterCurrentThread): Call
|
||||||
objc_thread_add before creating the NSThread object using a method
|
objc_thread_add before creating the NSThread object using a method
|
||||||
call.
|
call. (GSUnregisterCurrentThread): Post the NSThreadWillExit
|
||||||
|
notification.
|
||||||
|
|
||||||
2001-03-19 Jonathan Gapen <jagapen@home.com>
|
2001-03-19 Jonathan Gapen <jagapen@home.com>
|
||||||
|
|
||||||
* Source/NSString.m: In ([-rangeOfComposedCharacterSequenceAtIndex:]),
|
* Source/NSString.m: In ([-rangeOfComposedCharacterSequenceAtIndex:]),
|
||||||
|
|
|
@ -93,7 +93,8 @@ GS_EXPORT BOOL GSRegisterCurrentThread (void);
|
||||||
* registerCurrentThread (). This method is basically the same as
|
* registerCurrentThread (). This method is basically the same as
|
||||||
* `+exit', but does not exit the thread - just destroys all objects
|
* `+exit', but does not exit the thread - just destroys all objects
|
||||||
* associated with the thread. Warning: using any GNUstep code after
|
* 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);
|
GS_EXPORT void GSUnregisterCurrentThread (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -475,15 +475,35 @@ void
|
||||||
GSUnregisterCurrentThread (void)
|
GSUnregisterCurrentThread (void)
|
||||||
{
|
{
|
||||||
NSThread *thread;
|
NSThread *thread;
|
||||||
|
static NSNotificationCenter *nc = nil;
|
||||||
|
static Class notificationClass = Nil;
|
||||||
|
|
||||||
|
if (nc == nil)
|
||||||
|
{
|
||||||
|
nc = [NSNotificationCenter defaultCenter];
|
||||||
|
notificationClass = [NSNotification class];
|
||||||
|
}
|
||||||
|
|
||||||
thread = GSCurrentThread();
|
thread = GSCurrentThread();
|
||||||
|
|
||||||
if (thread->_active == YES)
|
if (thread->_active == YES)
|
||||||
{
|
{
|
||||||
|
NSNotification *n;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
* destroy the thread object.
|
||||||
|
|
Loading…
Reference in a new issue