NSConditionLock

A synchronization tool that combines a condition variable with an integer value. Used to synchronize threads based on state values.

Base Class

NSCondition

Instance Variables

mulle_atomic_pointer_t   _currentCondition;  // The current condition value

Methods

Initialization

Condition Access

Locking Operations

Usage Example

NSConditionLock *lock = [[NSConditionLock alloc] initWithCondition:0];

// Wait for condition 0
[lock lockWhenCondition:0];
// ... do work ...
[lock unlockWithCondition:1];  // Signal completion

// Wait for condition 1
[lock lockWhenCondition:1];
// ... do more work ...
[lock unlockWithCondition:2];

Important Notes

  1. Thread Safety
  2. Performance
  3. Implementation Details