Copyright ©1995 by NeXT Computer, Inc. All Rights Reserved.
|An NXLock is used to protect regions of code that can consume long periods of time, such as disk I/O or heavy computations. A lock is created once and is subsequently used to protect one or more regions of code. If a region of code is in use, an NXLock waits using the condition_wait() function, so the thread doesn't busy-wait. The following example shows the use of an NXLock:|
NXLock *theLock = [[NXLock alloc] init]; // done once!
/* ... other code */
/* ... possibly a long time of fussing with global data... */
|The NXConditionLock, NXLock, NXRecursiveLock, and NXSpinLock classes all implement the NXLock protocol with various features and performance characteristics; see the other class descriptions for more information.|
|None declared in this class.|
|Acquire or release a lock||lock|
|Waits until the lock isn't in use, using condition_wait() if necessary, then grabs the lock.|
|Releases the lock, using condition_signal() to signal the next party that the lock is available.|