mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
NSThread updates and cleanup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25608 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ef82327d8e
commit
15ffb48291
5 changed files with 28 additions and 11 deletions
|
@ -1,6 +1,8 @@
|
|||
2007-11-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSThread.h: Add new methods from MacOS 10.5
|
||||
Add new ivars to match. Add _reserved to preserve binary
|
||||
compatibility over future changes. Make all ivars private.
|
||||
* Source/NSThread.m: Implement some new MacOS-5 stuff and add stubs
|
||||
for stack size and thread cancellation.
|
||||
* Source/NSException.m Implement ([NSThread+callStackReturnAddresses])
|
||||
|
|
|
@ -40,18 +40,19 @@ extern "C" {
|
|||
|
||||
@interface NSThread : NSObject
|
||||
{
|
||||
@private
|
||||
id _target;
|
||||
id _arg;
|
||||
SEL _selector;
|
||||
NSString *_name;
|
||||
unsigned _stackSize;
|
||||
@public
|
||||
BOOL _cancelled;
|
||||
BOOL _active;
|
||||
NSHandler *_exception_handler;
|
||||
NSMutableDictionary *_thread_dictionary;
|
||||
struct autorelease_thread_vars _autorelease_vars;
|
||||
id _gcontext;
|
||||
void *_reserved; // For mfuture expansion
|
||||
}
|
||||
|
||||
+ (NSThread*) currentThread;
|
||||
|
@ -115,6 +116,10 @@ extern "C" {
|
|||
*/
|
||||
- (BOOL) isMainThread;
|
||||
|
||||
/** FIXME ... what does this do?
|
||||
*/
|
||||
- (void) main;
|
||||
|
||||
/** Returns the name of the receiver.
|
||||
*/
|
||||
- (NSString*) name;
|
||||
|
|
|
@ -47,7 +47,8 @@ static unsigned pool_count_warning_threshhold = UINT_MAX;
|
|||
#define BEGINNING_POOL_SIZE 32
|
||||
|
||||
/* Easy access to the thread variables belonging to NSAutoreleasePool. */
|
||||
#define ARP_THREAD_VARS (&(GSCurrentThread()->_autorelease_vars))
|
||||
typedef struct { @defs(NSThread) } *TInfo;
|
||||
#define ARP_THREAD_VARS (&(((TInfo)GSCurrentThread())->_autorelease_vars))
|
||||
|
||||
|
||||
@interface NSAutoreleasePool (Private)
|
||||
|
@ -229,7 +230,7 @@ static IMP initImp;
|
|||
|
||||
+ (void) addObject: (id)anObj
|
||||
{
|
||||
NSThread *t = GSCurrentThread();
|
||||
TInfo t = (TInfo)GSCurrentThread();
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = t->_autorelease_vars.current_pool;
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "Foundation/NSValue.h"
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct { @defs(NSThread) } *TInfo;
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
static NSString *
|
||||
GSPrivateBaseAddress(void *addr, void **base)
|
||||
|
@ -803,7 +805,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
|
|||
- (void) raise
|
||||
{
|
||||
#ifndef _NATIVE_OBJC_EXCEPTIONS
|
||||
NSThread *thread;
|
||||
TInfo thread;
|
||||
NSHandler *handler;
|
||||
#endif
|
||||
|
||||
|
@ -834,7 +836,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
|
|||
#ifdef _NATIVE_OBJC_EXCEPTIONS
|
||||
@throw self;
|
||||
#else
|
||||
thread = GSCurrentThread();
|
||||
thread = (TInfo)GSCurrentThread();
|
||||
handler = thread->_exception_handler;
|
||||
if (handler == NULL)
|
||||
{
|
||||
|
@ -962,9 +964,9 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
|
|||
void
|
||||
_NSAddHandler (NSHandler* handler)
|
||||
{
|
||||
NSThread *thread;
|
||||
TInfo thread;
|
||||
|
||||
thread = GSCurrentThread();
|
||||
thread = (TInfo)GSCurrentThread();
|
||||
#if defined(__MINGW32__) && defined(DEBUG)
|
||||
if (thread->_exception_handler
|
||||
&& IsBadReadPtr(thread->_exception_handler, sizeof(NSHandler)))
|
||||
|
@ -979,9 +981,9 @@ _NSAddHandler (NSHandler* handler)
|
|||
void
|
||||
_NSRemoveHandler (NSHandler* handler)
|
||||
{
|
||||
NSThread *thread;
|
||||
TInfo thread;
|
||||
|
||||
thread = GSCurrentThread();
|
||||
thread = (TInfo)GSCurrentThread();
|
||||
#if defined(DEBUG)
|
||||
if (thread->_exception_handler != handler)
|
||||
{
|
||||
|
|
|
@ -306,6 +306,8 @@ GSCurrentThread(void)
|
|||
return t;
|
||||
}
|
||||
|
||||
typedef struct { @defs(NSThread) } *TInfo;
|
||||
|
||||
/**
|
||||
* Fast access function for thread dictionary of current thread.<br />
|
||||
* If there is no dictionary, creates the dictionary.
|
||||
|
@ -323,7 +325,7 @@ GSDictionaryForThread(NSThread *t)
|
|||
}
|
||||
else
|
||||
{
|
||||
NSMutableDictionary *dict = t->_thread_dictionary;
|
||||
NSMutableDictionary *dict = ((TInfo)t)->_thread_dictionary;
|
||||
|
||||
if (dict == nil)
|
||||
{
|
||||
|
@ -802,6 +804,11 @@ gnustep_base_thread_callback(void)
|
|||
return (self == defaultThread ? YES : NO);
|
||||
}
|
||||
|
||||
- (void) main
|
||||
{
|
||||
[_target performSelector: _selector withObject: _arg];
|
||||
}
|
||||
|
||||
- (NSString*) name
|
||||
{
|
||||
return _name;
|
||||
|
@ -844,7 +851,7 @@ gnustep_base_thread_callback(void)
|
|||
object: self
|
||||
userInfo: nil];
|
||||
|
||||
[_target performSelector: _selector withObject: _arg];
|
||||
[self main];
|
||||
[NSThread exit];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue