Include <gnustep/base/preface.h> first! Fix indentation.

([NSLock +initialize]): Method removed.
([NSLock -init]): Assert return value from objc_mutex_allocate(),
don't just return nil.
([NSConditionLock -initWithCondition:]): Likewise.
([NSRecursiveLock -init]): Likewise.
([NSConditionLock +initialize]): Method removed.
([NSRecursiveLock +initialize]): Method removed.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1566 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-05-28 13:37:17 +00:00
parent 9f4e247b78
commit 28d87a29cd

View file

@ -1,12 +1,8 @@
/*
NSLock.m
Mutual exclusion locking classes
/* Mutual exclusion locking classes
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Created: 1996
This file is part of the GNUstep Objective-C Library.
@ -20,42 +16,27 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gnustep/base/preface.h>
#include <Foundation/NSLock.h>
//
// NSLock class
// Simplest lock for protecting critical sections of code
//
@implementation NSLock
// Class initialization
+ (void)initialize
{
if (self == [NSLock class])
{
// Initial version
[self setVersion:1];
}
}
// Default initializer
// Designated initializer
- init
{
[super init];
// Allocate the mutex from the runtime
mutex = objc_mutex_allocate();
if (!mutex)
return nil;
else
NSAssertParameter (mutex);
return self;
}
@ -64,7 +45,6 @@
// Ask the runtime to deallocate the mutex
// If there are outstanding locks then it will block
objc_mutex_deallocate (mutex);
[super dealloc];
}
@ -95,28 +75,18 @@
@end
//
// NSConditionLock
// Allows locking and unlocking to be based upon a condition
//
@implementation NSConditionLock
// Allows locking and unlocking to be based upon an integer condition
// Class initialization
+ (void)initialize
{
if (self == [NSConditionLock class])
{
// Initial version
[self setVersion:1];
}
}
@implementation NSConditionLock
- init
{
return [self initWithCondition: 0];
}
// Default initializer
// Designated initializer
// Initialize lock with condition
- (id)initWithCondition:(int)value
{
@ -126,9 +96,7 @@
// Allocate the mutex from the runtime
mutex = objc_mutex_allocate ();
if (!mutex)
return nil;
else
NSParameterAssert (mutex);
return self;
}
@ -137,7 +105,6 @@
// Ask the runtime to deallocate the mutex
// If there are outstanding locks then it will block
objc_mutex_deallocate (mutex);
[super dealloc];
}
@ -233,36 +200,23 @@
@end
//
// NSRecursiveLock
// Allows the lock to be recursively acquired by the same thread
//
// If the same thread locks the mutex (n) times then that same
// thread must also unlock it (n) times before another thread
// can acquire the lock.
//
@implementation NSRecursiveLock
// Class initialization
+ (void)initialize
{
if (self == [NSRecursiveLock class])
{
// Initial version
[self setVersion:1];
}
}
@implementation NSRecursiveLock
// Default initializer
- init
{
[super init];
// Allocate the mutex from the runtime
mutex = objc_mutex_allocate();
if (!mutex)
return nil;
else
NSParameterAssert (mutex);
return self;
}
@ -271,7 +225,6 @@
// Ask the runtime to deallocate the mutex
// If there are outstanding locks then it will block.
objc_mutex_deallocate(mutex);
[super dealloc];
}