Up

# NSLock+GNUstepBase documentation

### Authors

Richard Frith-Macdonald (`rfm@gnu.org`)

Date: Generated at 2025-02-13 06:02:40 +0000

Copyright: (C) 2003-2010 Free Software Foundation, Inc.

### Contents -

1. Software documentation for the NSLock(GNUstepBase) category
2. Software documentation for the NSRecursiveLock(GNUstepBase) category

# Software documentation for the NSLock(GNUstepBase) category

## NSLock(GNUstepBase)

> Declared in:
>   GNUstepBase/NSLock+GNUstepBase.h

Availability: Not in OpenStep/MacOS-X
Returns IDENT which will be initialized to an instance of a CLASSNAME in a thread safe manner. If IDENT has been previously initialized this macro merely returns IDENT. IDENT is considered uninitialized, if it contains `nil`. CLASSNAME must be either NSLock, NSRecursiveLock or one of their subclasses. See [NSLock(GNUstepBase) +newLockAt:] for details. This macro is intended for code that cannot insure that a lock can be initialized in thread safe manner otherwise.

     NSLock *my_lock = nil;

     void function (void)
     {
       [GS_INITIALIZED_LOCK(my_lock, NSLock) lock];
       do_work ();
       [my_lock unlock];
     }

Method summary

- +newLockAt:

### newLockAt:

+ (id) newLockAt: (id*)location;
Availability: Not in OpenStep/MacOS-X
Initializes the id pointed to by location with a new instance of the receiver's class in a thread safe manner, unless it has been previously initialized. Returns the contents pointed to by location. The location is considered unintialized if it contains `nil`.
This method is used in the GS_INITIALIZED_LOCK macro to initialize lock variables when it cannot be insured that they can be initialized in a thread safe environment.

     NSLock *my_lock = nil;

     void function (void)
     {
       [GS_INITIALIZED_LOCK(my_lock, NSLock) lock];
       do_work ();
       [my_lock unlock];
     }

# Software documentation for the NSRecursiveLock(GNUstepBase) category

## NSRecursiveLock(GNUstepBase)

> Declared in:
>   GNUstepBase/NSLock+GNUstepBase.h

Availability: Not in OpenStep/MacOS-X
Description forthcoming.
Method summary

- +newLockAt:

### newLockAt:

+ (id) newLockAt: (id*)location;
Availability: Not in OpenStep/MacOS-X
Initializes the id pointed to by location with a new instance of the receiver's class in a thread safe manner, unless it has been previously initialized. Returns the contents pointed to by location. The location is considered unintialized if it contains `nil`.
This method is used in the GS_INITIALIZED_LOCK macro to initialize lock variables when it cannot be insured that they can be initialized in a thread safe environment.

     NSLock *my_lock = nil;

     void function (void)
     {
       [GS_INITIALIZED_LOCK(my_lock, NSLock) lock];
       do_work ();
       [my_lock unlock];
     }

Up