ftp.nice.ch/peanuts/GeneralData/Documents/openstep/OpenStepSpec_rtf.tar.gz#/OpenStepSpec_rtf/FoundationKit/Classes/NSRecursiveLock.rtf

This is NSRecursiveLock.rtf in view mode; [Download] [Up]

paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc.  All Rights Reserved.

s8 li100 fi0 ri1007 ql f0 b fs36 fs100 
fs36 NSRecursiveLock 
pard s21 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 
fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSObject
fs20 
fs28 s12 f0 b fs24 Conforms To:tab b0 fs28 f1 NSLocking
fi0 NSObject (NSObject)
fs20 
fs28 s13 fi-2771 f0 b fs24 Declared In:tab b0 fs28 f1 Foundation/NSLock.h 
fs20 
fs28 pard s35 li100 fi0 ri1007 ql f0 b fs28 fs20 
fs28 Class Description
fs14 
fs28 pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 
fs28 NSRecursiveLock is used for locks that need to be reacquired by the same thread.
fs16 
fs28 An NSRecursiveLock locks a critical section of code such that a single thread can reaquire the lock multiple times without deadlocking, while preventing access by other threads. (Note that this implies that a recursive lock will not protect a critical section from a signal handler interrupting the thread holding the lock.) Here is an example where a recursive lock functions properly but other lock types would deadlock:
fs16 
fs28 pard s10 li1231 fi0 ri1007 ql f2 fs20 // create the lock only once!
NSRecursiveLock  *theLock = [NSRecursiveLock new];
/* ...other code... */
[theLock lock];

/* ... possibly a long time of fussing with global data... */
[theLock lock]; /* possibly invoked in a subroutine */
[theLock unlock];
    
[theLock unlock];
pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 fs28 fs16 
fs28 The NSConditionLock, NSLock, and NSRecursiveLock classes all implement the NSLocking protocol with various features and performance characteristics; see the other class descriptions for more information.
fs16 
fs28 pard s35 li100 fi0 ri1007 ql f0 b fs24 
fs28 Acquiring a Lock
fs14 
fs28 pard s14 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (BOOL)b tryLockb0 tab Attempts to acquire a lock. Returns YES if successful and NO otherwise. This method can be called repeatedly to produce nested locks.
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.