Class

NSConditionLock

The NSConditionLock class defines objects whose locks can be associated with specific, user-defined conditions. Using an NSConditionLock object, you can ensure that a thread can acquire a lock only if a certain condition is met. Once it has acquired the lock and executed the critical section of code, the thread can relinquish the lock and set the associated condition to something new. The conditions themselves are arbitrary: you define them as needed for your application.

Symbols

Initializing an NSConditionLock Object

init(condition: Int)

Initializes a newly allocated NSConditionLock object and sets its condition.

Accessing the Condition

var condition: Int

The condition associated with the receiver.

Acquiring and Releasing a Lock

func lock(before: Date)

Attempts to acquire a lock before a specified moment in time.

func lock(whenCondition: Int)

Attempts to acquire a lock.

func lock(whenCondition: Int, before: Date)

Attempts to acquire a lock before a specified moment in time.

func `try`()

Attempts to acquire a lock without regard to the receiver’s condition.

func tryLock(whenCondition: Int)

Attempts to acquire a lock if the receiver’s condition is equal to the specified condition.

func unlock(withCondition: Int)

Relinquishes the lock and sets the receiver’s condition.

Identifying the Condition Lock

var name: String?

The name associated with the receiver.

Relationships

Inherits From