mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 09:31:07 +00:00
tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7512 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6f6debd1e6
commit
39810508b6
1 changed files with 58 additions and 37 deletions
|
@ -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
|
||||||
|
|
||||||
|
@ -88,6 +89,8 @@ 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
|
||||||
|
@ -96,6 +99,7 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
|
||||||
NSWarnMLog(@"objc_mutex_deallocate() failed");
|
NSWarnMLog(@"objc_mutex_deallocate() failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try to acquire the lock
|
// Try to acquire the lock
|
||||||
// Does not block
|
// Does not block
|
||||||
|
@ -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,17 +230,24 @@ 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
|
||||||
- (int) condition
|
- (int) condition
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,6 +496,8 @@ 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
|
||||||
|
@ -486,6 +506,7 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
|
||||||
NSWarnMLog(@"objc_mutex_deallocate() failed");
|
NSWarnMLog(@"objc_mutex_deallocate() failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try to acquire the lock
|
// Try to acquire the lock
|
||||||
// Does not block
|
// Does not block
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue