# NSLock+GNUstepBase documentation

rfm@gnu.org
Generated at 2025-02-13 06:02:40 +0000
2003-2010 Free Software Foundation, Inc.
Software documentation for the NSLock(GNUstepBase) category
GNUstepBase/NSLock+GNUstepBase.h
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]; }
newLockAt:
location
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
GNUstepBase/NSLock+GNUstepBase.h
Description forthcoming.
newLockAt:
location
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]; }