Class

NSConditionLock

A lock that can be associated with specific, user-defined conditions.

Declaration

@interface NSConditionLock : NSObject

Overview

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.

Topics

Initializing an NSConditionLock Object

- initWithCondition:

Initializes a newly allocated NSConditionLock object and sets its condition.

Accessing the Condition

condition

The condition associated with the receiver.

Acquiring and Releasing a Lock

- lockBeforeDate:

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

- lockWhenCondition:

Attempts to acquire a lock.

- lockWhenCondition:beforeDate:

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

- tryLock

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

- tryLockWhenCondition:

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

- unlockWithCondition:

Relinquishes the lock and sets the receiver’s condition.

Identifying the Condition Lock

name

The name associated with the receiver.

Relationships

Inherits From

Conforms To

See Also

Threads and Locking

NSThread

A thread of execution.

NSLocking

The elementary methods adopted by classes that define lock objects.

NSLock

An object that coordinates the operation of multiple threads of execution within the same application.

NSRecursiveLock

A lock that may be acquired multiple times by the same thread without causing a deadlock.

NSDistributedLock

A lock that multiple applications on multiple hosts can use to restrict access to some shared resource, such as a file.

NSCondition

A condition variable whose semantics follow those used for POSIX-style conditions.