Up

NSDistributedLock class reference

Authors

Richard Frith-Macdonald (richard@brainstorm.co.uk)

Version: 35503

Date: 2012-09-03 14:36:45 +0100 (Mon, 03 Sep 2012)

Copyright: (C) 1997 Free Software Foundation, Inc.

Software documentation for the NSDistributedLock class

NSDistributedLock : NSObject

Declared in:
Foundation/NSDistributedLock.h
Availability: OpenStep

This class does not adopt the <NSLocking> protocol but supports locking across processes, including processes on different machines, as long as they can access a common filesystem.

Instance Variables

Method summary

lockWithPath: 

+ (NSDistributedLock*) lockWithPath: (NSString*)aPath;
Availability: OpenStep

Return a distributed lock for aPath. See -initWithPath: for details.

breakLock 

- (void) breakLock;
Availability: OpenStep

Forces release of the lock whether the receiver owns it or not.
Raises an NSGenericException if unable to remove the lock.

initWithPath: 

- (id) initWithPath: (NSString*)aPath;
Availability: OpenStep

Initialises the receiver with the specified filesystem path.
The location in the filesystem must be accessible for this to be usable. That is, the processes using the lock must be able to access, create, and destroy files at the path.
The directory in which the last path component resides must already exist... create it using NSFileManager if you need to.

lockDate 

- (NSDate*) lockDate;
Availability: OpenStep

Returns the date at which the lock was acquired by any NSDistributedLock using the same path. If nothing has the lock, this returns nil .

tryLock 

- (BOOL) tryLock;
Availability: OpenStep

Attempt to acquire the lock and return YES on success, NO on failure.
May raise an NSGenericException if a problem occurs.

unlock 

- (void) unlock;
Availability: OpenStep

Releases the lock. Raises an NSGenericException if unable to release the lock (for instance if the receiver does not own it or another process has broken it).



Instance Variables for NSDistributedLock Class

_lockPath

@protected NSString* _lockPath;
Availability: OpenStep

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_lockTime

@protected NSDate* _lockTime;
Availability: OpenStep

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.





Up