Copyright ©1995 by NeXT Computer, Inc. All Rights Reserved.
|An NXSpinLock is used to lock short sections of code that take very little time to execute. 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 NXSpinLock will busy-wait until the lock is released. An NXSpinLock can be acquired very quickly, but will consume CPU resources as long as the lock is held by another party. The following example shows the use of an NXSpinLock:|
NXSpinLock *theLock = [[NXSpinLock alloc] init];
// done once!
/* ... other code */
/* ... short quick section of atomic code... */
|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|
|Uses mutex_lock() to busy-wait until the lock isn't in use and grab the lock.|
|Releases the lock with mutex_unlock(), allowing the next party to access the critical section of code.|