git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7512 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-09-14 09:37:13 +00:00
parent 6f6debd1e6
commit 39810508b6

View file

@ -27,6 +27,7 @@
#include <base/preface.h> #include <base/preface.h>
#include <Foundation/NSLock.h> #include <Foundation/NSLock.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSDebug.h>
// Exceptions // Exceptions
@ -89,12 +90,15 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
- (void) gcFinalize - (void) gcFinalize
{ {
if (_mutex != 0)
{
// Ask the runtime to deallocate the mutex // Ask the runtime to deallocate the mutex
// If there are outstanding locks then it will block // If there are outstanding locks then it will block
if (objc_mutex_deallocate(_mutex) == -1) if (objc_mutex_deallocate(_mutex) == -1)
{ {
NSWarnMLog(@"objc_mutex_deallocate() failed"); NSWarnMLog(@"objc_mutex_deallocate() failed");
} }
}
} }
// Try to acquire the lock // Try to acquire the lock
@ -194,23 +198,27 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
// Initialize lock with condition // Initialize lock with condition
- (id) initWithCondition: (int)value - (id) initWithCondition: (int)value
{ {
[super init]; self = [super init];
if (self != nil)
{
_condition_value = value; _condition_value = value;
// Allocate the mutex from the runtime // Allocate the mutex from the runtime
_condition = objc_condition_allocate (); _condition = objc_condition_allocate ();
if (!_condition) if (_condition == 0)
{ {
NSLog(@"Failed to allocate a condition"); NSLog(@"Failed to allocate a condition");
RELEASE(self);
return nil; return nil;
} }
_mutex = objc_mutex_allocate (); _mutex = objc_mutex_allocate ();
if (!_mutex) if (_mutex == 0)
{ {
NSLog(@"Failed to allocate a mutex"); NSLog(@"Failed to allocate a mutex");
RELEASE(self);
return nil; return nil;
} }
}
return self; return self;
} }
@ -222,16 +230,23 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
- (void) gcFinalize - (void) gcFinalize
{ {
// Ask the runtime to deallocate the mutex if (_condition != 0)
// If there are outstanding locks then it will block {
// Ask the runtime to deallocate the condition
if (objc_condition_deallocate(_condition) == -1) if (objc_condition_deallocate(_condition) == -1)
{ {
NSWarnMLog(@"objc_condition_deallocate() failed"); NSWarnMLog(@"objc_condition_deallocate() failed");
} }
}
if (_mutex != 0)
{
// Ask the runtime to deallocate the mutex
// If there are outstanding locks then it will block
if (objc_mutex_deallocate(_mutex) == -1) if (objc_mutex_deallocate(_mutex) == -1)
{ {
NSWarnMLog(@"objc_mutex_deallocate() failed"); NSWarnMLog(@"objc_mutex_deallocate() failed");
} }
}
} }
// Return the current condition of the lock // Return the current condition of the lock
@ -459,15 +474,18 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
// Designated initializer // Designated initializer
- (id) init - (id) init
{ {
[super init]; self = [super init];
if (self != nil)
{
// Allocate the mutex from the runtime // Allocate the mutex from the runtime
_mutex = objc_mutex_allocate(); _mutex = objc_mutex_allocate();
if (!_mutex) if (_mutex == 0)
{ {
NSLog(@"Failed to allocate a mutex"); NSLog(@"Failed to allocate a mutex");
RELEASE(self);
return nil; return nil;
} }
}
return self; return self;
} }
@ -479,12 +497,15 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
- (void) gcFinalize - (void) gcFinalize
{ {
if (_mutex != 0)
{
// Ask the runtime to deallocate the mutex // Ask the runtime to deallocate the mutex
// If there are outstanding locks then it will block // If there are outstanding locks then it will block
if (objc_mutex_deallocate(_mutex) == -1) if (objc_mutex_deallocate(_mutex) == -1)
{ {
NSWarnMLog(@"objc_mutex_deallocate() failed"); NSWarnMLog(@"objc_mutex_deallocate() failed");
} }
}
} }
// Try to acquire the lock // Try to acquire the lock