mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-10 16:20:42 +00:00
More simplification by using lazy locking
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18559 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4b431aa0cc
commit
5ffc526cbc
9 changed files with 37 additions and 350 deletions
|
@ -2,6 +2,15 @@
|
|||
|
||||
* Source/NSConection.m: Simplify code by using GSLazyLock and
|
||||
GSRecursiveLazylock. Removed unused include of float.h
|
||||
* Source/GSAttributedString.m:
|
||||
* Source/GSTcpPort.m:
|
||||
* Source/NSCharacterSet.m:
|
||||
* Source/NSCountedSet.m:
|
||||
* Source/NSDebug.m:
|
||||
* Source/NSMessagePort.m:
|
||||
* Source/NSSocketPort.m:
|
||||
* Source/NSTimeZone.m:
|
||||
Simplify by using lazy locking.
|
||||
|
||||
2004-02-07 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSAttributedString.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSRange.h"
|
||||
|
@ -427,34 +428,15 @@ _attributesAtIndexEffectiveRange(
|
|||
return nil;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are multi-threaded, we must guard access to the uniquing set.
|
||||
*/
|
||||
+ (void) _becomeThreaded: (id)notification
|
||||
{
|
||||
attrLock = [NSLock new];
|
||||
lockSel = @selector(lock);
|
||||
unlockSel = @selector(unlock);
|
||||
lockImp = [attrLock methodForSelector: lockSel];
|
||||
unlockImp = [attrLock methodForSelector: unlockSel];
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
_setup();
|
||||
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
attrLock = [GSLazyLock new];
|
||||
lockSel = @selector(lock);
|
||||
unlockSel = @selector(unlock);
|
||||
lockImp = [attrLock methodForSelector: lockSel];
|
||||
unlockImp = [attrLock methodForSelector: unlockSel];
|
||||
}
|
||||
|
||||
- (id) initWithString: (NSString*)aString
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSException.h"
|
||||
|
@ -97,8 +98,6 @@
|
|||
|
||||
#endif /* !__MINGW__ */
|
||||
|
||||
static BOOL multi_threaded = NO;
|
||||
|
||||
/*
|
||||
* Largest chunk of data possible in DO
|
||||
*/
|
||||
|
@ -431,10 +430,7 @@ static Class runLoopClass;
|
|||
handle = (GSTcpHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone());
|
||||
handle->desc = d;
|
||||
handle->wMsgs = [NSMutableArray new];
|
||||
if (multi_threaded == YES)
|
||||
{
|
||||
handle->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
handle->myLock = [GSLazyRecursiveLock new];
|
||||
handle->valid = YES;
|
||||
return AUTORELEASE(handle);
|
||||
}
|
||||
|
@ -1277,62 +1273,6 @@ static NSRecursiveLock *tcpPortLock = nil;
|
|||
static NSMapTable *tcpPortMap = 0;
|
||||
static Class tcpPortClass;
|
||||
|
||||
/*
|
||||
* When the system becomes multithreaded, we set a flag to say so and
|
||||
* make sure that port and handle locking is enabled.
|
||||
*/
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification
|
||||
{
|
||||
if (multi_threaded == NO)
|
||||
{
|
||||
NSMapEnumerator pEnum;
|
||||
NSMapTable *m;
|
||||
void *dummy;
|
||||
|
||||
multi_threaded = YES;
|
||||
if (tcpPortLock == nil)
|
||||
{
|
||||
tcpPortLock = [NSRecursiveLock new];
|
||||
}
|
||||
pEnum = NSEnumerateMapTable(tcpPortMap);
|
||||
while (NSNextMapEnumeratorPair(&pEnum, &dummy, (void**)&m))
|
||||
{
|
||||
NSMapEnumerator mEnum;
|
||||
GSTcpPort *p;
|
||||
|
||||
mEnum = NSEnumerateMapTable(m);
|
||||
while (NSNextMapEnumeratorPair(&mEnum, &dummy, (void**)&p))
|
||||
{
|
||||
if ([p isValid] == YES)
|
||||
{
|
||||
NSMapEnumerator hEnum;
|
||||
GSTcpHandle *h;
|
||||
|
||||
if (p->myLock == nil)
|
||||
{
|
||||
p->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
hEnum = NSEnumerateMapTable(p->handles);
|
||||
while (NSNextMapEnumeratorPair(&hEnum, &dummy, (void**)&h))
|
||||
{
|
||||
if ([h isValid] == YES && h->myLock == nil)
|
||||
{
|
||||
h->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&hEnum);
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&mEnum);
|
||||
}
|
||||
NSEndMapTableEnumeration(&pEnum);
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver: self
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
static unsigned wordAlign;
|
||||
#endif
|
||||
|
@ -1348,18 +1288,7 @@ static unsigned wordAlign;
|
|||
tcpPortMap = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
tcpPortLock = [GSLazyRecursiveLock new];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1455,10 +1384,7 @@ static unsigned wordAlign;
|
|||
port->address = [addr copy];
|
||||
port->handles = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 0);
|
||||
if (multi_threaded == YES)
|
||||
{
|
||||
port->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
port->myLock = [GSLazyRecursiveLock new];
|
||||
port->_is_valid = YES;
|
||||
|
||||
if (shouldListen == YES && [thisHost isEqual: aHost])
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSBitmapCharSet.h"
|
||||
#include "Foundation/NSException.h"
|
||||
|
@ -46,18 +47,6 @@ static Class abstractClass = nil;
|
|||
|
||||
@implementation NSCharacterSet
|
||||
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification
|
||||
{
|
||||
if (cache_lock == nil)
|
||||
{
|
||||
cache_lock = [NSLock new];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver: self
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
static BOOL one_time = NO;
|
||||
|
@ -67,18 +56,7 @@ static Class abstractClass = nil;
|
|||
abstractClass = [NSCharacterSet class];
|
||||
one_time = YES;
|
||||
}
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
cache_lock = [GSLazyLock new];
|
||||
}
|
||||
|
||||
/* Provide a default object for allocation */
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
|
@ -47,10 +48,6 @@ static IMP lockImp = 0;
|
|||
static IMP unlockImp = 0;
|
||||
static BOOL uniquing = NO;
|
||||
|
||||
@interface NSCountedSet (GSThreading)
|
||||
+ (void) _becomeThreaded: (id)notification;
|
||||
@end
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The NSCountedSet class is used to maintain a set of objects where
|
||||
|
@ -73,18 +70,9 @@ static Class NSCountedSet_concrete_class;
|
|||
{
|
||||
NSCountedSet_abstract_class = self;
|
||||
NSCountedSet_concrete_class = [GSCountedSet class];
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
uniqueLock = [GSLazyLock new];
|
||||
lockImp = [uniqueLock methodForSelector: @selector(lock)];
|
||||
unlockImp = [uniqueLock methodForSelector: @selector(unlock)];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,18 +287,6 @@ static Class NSCountedSet_concrete_class;
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation NSCountedSet (GSThreading)
|
||||
/*
|
||||
* If we are multi-threaded, we must guard access to the uniquing set.
|
||||
*/
|
||||
+ (void) _becomeThreaded: (id)notification
|
||||
{
|
||||
uniqueLock = [NSLock new];
|
||||
lockImp = [uniqueLock methodForSelector: @selector(lock)];
|
||||
unlockImp = [uniqueLock methodForSelector: @selector(unlock)];
|
||||
}
|
||||
@end
|
||||
|
||||
/**
|
||||
* This function purges the global NSCountedSet object used for
|
||||
* uniquing. It handles locking as necessary. It can be used to
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSString.h"
|
||||
|
@ -70,32 +71,13 @@ void (*_GSDebugAllocationRemoveFunc)(Class c, id o) = _GSDebugAllocationRemove;
|
|||
|
||||
@interface GSDebugAlloc : NSObject
|
||||
+ (void) initialize;
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification;
|
||||
@end
|
||||
|
||||
@implementation GSDebugAlloc
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
uniqueLock = [GSLazyRecursiveLock new];
|
||||
}
|
||||
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification
|
||||
{
|
||||
uniqueLock = [NSRecursiveLock new];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSException.h"
|
||||
|
@ -104,8 +105,6 @@
|
|||
(sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
|
||||
#endif
|
||||
|
||||
static BOOL multi_threaded = NO;
|
||||
|
||||
/*
|
||||
* Largest chunk of data possible in DO
|
||||
*/
|
||||
|
@ -343,10 +342,7 @@ static Class runLoopClass;
|
|||
handle = (GSMessageHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone());
|
||||
handle->desc = d;
|
||||
handle->wMsgs = [NSMutableArray new];
|
||||
if (multi_threaded == YES)
|
||||
{
|
||||
handle->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
handle->myLock = [GSLazyRecursiveLock new];
|
||||
handle->valid = YES;
|
||||
return AUTORELEASE(handle);
|
||||
}
|
||||
|
@ -1167,54 +1163,6 @@ static void clean_up_sockets(void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* When the system becomes multithreaded, we set a flag to say so and
|
||||
* make sure that port and handle locking is enabled.
|
||||
*/
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification
|
||||
{
|
||||
if (multi_threaded == NO)
|
||||
{
|
||||
NSMapEnumerator mEnum;
|
||||
NSMessagePort *p;
|
||||
void *dummy;
|
||||
|
||||
multi_threaded = YES;
|
||||
if (messagePortLock == nil)
|
||||
{
|
||||
messagePortLock = [NSRecursiveLock new];
|
||||
}
|
||||
mEnum = NSEnumerateMapTable(messagePortMap);
|
||||
while (NSNextMapEnumeratorPair(&mEnum, &dummy, (void**)&p))
|
||||
{
|
||||
if ([p isValid] == YES)
|
||||
{
|
||||
NSMapEnumerator hEnum;
|
||||
GSMessageHandle *h;
|
||||
|
||||
if (p->myLock == nil)
|
||||
{
|
||||
p->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
hEnum = NSEnumerateMapTable(p->handles);
|
||||
while (NSNextMapEnumeratorPair(&hEnum, &dummy, (void**)&h))
|
||||
{
|
||||
if ([h isValid] == YES && h->myLock == nil)
|
||||
{
|
||||
h->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&hEnum);
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&mEnum);
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver: self
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
static unsigned wordAlign;
|
||||
#endif
|
||||
|
@ -1230,18 +1178,7 @@ static unsigned wordAlign;
|
|||
messagePortMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
messagePortLock = [GSLazyRecursiveLock new];
|
||||
atexit(clean_up_sockets);
|
||||
}
|
||||
}
|
||||
|
@ -1294,10 +1231,7 @@ static int unique_index = 0;
|
|||
port->listener = -1;
|
||||
port->handles = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 0);
|
||||
if (multi_threaded == YES)
|
||||
{
|
||||
port->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
port->myLock = [GSLazyRecursiveLock new];
|
||||
port->_is_valid = YES;
|
||||
|
||||
if (shouldListen == YES)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSException.h"
|
||||
|
@ -97,8 +98,6 @@
|
|||
|
||||
#endif /* !__MINGW__ */
|
||||
|
||||
static BOOL multi_threaded = NO;
|
||||
|
||||
/*
|
||||
* Largest chunk of data possible in DO
|
||||
*/
|
||||
|
@ -395,10 +394,7 @@ static Class runLoopClass;
|
|||
handle = (GSTcpHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone());
|
||||
handle->desc = d;
|
||||
handle->wMsgs = [NSMutableArray new];
|
||||
if (multi_threaded == YES)
|
||||
{
|
||||
handle->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
handle->myLock = [GSLazyRecursiveLock new];
|
||||
handle->valid = YES;
|
||||
return AUTORELEASE(handle);
|
||||
}
|
||||
|
@ -1256,62 +1252,6 @@ static NSRecursiveLock *tcpPortLock = nil;
|
|||
static NSMapTable *tcpPortMap = 0;
|
||||
static Class tcpPortClass;
|
||||
|
||||
/*
|
||||
* When the system becomes multithreaded, we set a flag to say so and
|
||||
* make sure that port and handle locking is enabled.
|
||||
*/
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification
|
||||
{
|
||||
if (multi_threaded == NO)
|
||||
{
|
||||
NSMapEnumerator pEnum;
|
||||
NSMapTable *m;
|
||||
void *dummy;
|
||||
|
||||
multi_threaded = YES;
|
||||
if (tcpPortLock == nil)
|
||||
{
|
||||
tcpPortLock = [NSRecursiveLock new];
|
||||
}
|
||||
pEnum = NSEnumerateMapTable(tcpPortMap);
|
||||
while (NSNextMapEnumeratorPair(&pEnum, &dummy, (void**)&m))
|
||||
{
|
||||
NSMapEnumerator mEnum;
|
||||
NSSocketPort *p;
|
||||
|
||||
mEnum = NSEnumerateMapTable(m);
|
||||
while (NSNextMapEnumeratorPair(&mEnum, &dummy, (void**)&p))
|
||||
{
|
||||
if ([p isValid] == YES)
|
||||
{
|
||||
NSMapEnumerator hEnum;
|
||||
GSTcpHandle *h;
|
||||
|
||||
if (p->myLock == nil)
|
||||
{
|
||||
p->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
hEnum = NSEnumerateMapTable(p->handles);
|
||||
while (NSNextMapEnumeratorPair(&hEnum, &dummy, (void**)&h))
|
||||
{
|
||||
if ([h isValid] == YES && h->myLock == nil)
|
||||
{
|
||||
h->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&hEnum);
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&mEnum);
|
||||
}
|
||||
NSEndMapTableEnumeration(&pEnum);
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver: self
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
static unsigned wordAlign;
|
||||
#endif
|
||||
|
@ -1327,18 +1267,7 @@ static unsigned wordAlign;
|
|||
tcpPortMap = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
tcpPortLock = [GSLazyRecursiveLock new];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1434,10 +1363,7 @@ static unsigned wordAlign;
|
|||
port->address = [addr copy];
|
||||
port->handles = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 0);
|
||||
if (multi_threaded == YES)
|
||||
{
|
||||
port->myLock = [NSRecursiveLock new];
|
||||
}
|
||||
port->myLock = [GSLazyRecursiveLock new];
|
||||
port->_is_valid = YES;
|
||||
|
||||
if (shouldListen == YES && [thisHost isEqual: aHost])
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -265,7 +266,6 @@ static NSString *_time_zone_path(NSString *subpath)
|
|||
|
||||
/* Private methods for obtaining resource file names. */
|
||||
@interface NSTimeZone (Private)
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification;
|
||||
+ (NSString*) getAbbreviationFile;
|
||||
+ (NSString*) getRegionsFile;
|
||||
+ (NSString*) getTimeZoneFile: (NSString*)name;
|
||||
|
@ -1015,18 +1015,7 @@ static NSMapTable *absolutes = 0;
|
|||
localTimeZone = [[NSLocalTimeZone alloc] init];
|
||||
|
||||
fake_abbrev_dict = [[NSInternalAbbrevDict alloc] init];
|
||||
if ([NSThread isMultiThreaded])
|
||||
{
|
||||
[self _becomeThreaded: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_becomeThreaded:)
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
zone_mutex = [GSLazyRecursiveLock new];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1488,21 +1477,6 @@ static NSMapTable *absolutes = 0;
|
|||
|
||||
@implementation NSTimeZone (Private)
|
||||
|
||||
/*
|
||||
* When the system becomes multithreaded, we set a flag to say so
|
||||
*/
|
||||
+ (void) _becomeThreaded: (NSNotification*)notification
|
||||
{
|
||||
if (zone_mutex == nil)
|
||||
{
|
||||
zone_mutex = [NSRecursiveLock new];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver: self
|
||||
name: NSWillBecomeMultiThreadedNotification
|
||||
object: nil];
|
||||
}
|
||||
|
||||
+ (NSString*) getAbbreviationFile
|
||||
{
|
||||
return _time_zone_path (ABBREV_DICT);
|
||||
|
|
Loading…
Reference in a new issue