Up

NSDistributedLock class reference

Authors

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

Version: 1.20

Date: 2005/02/22 11:22:44

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

Software documentation for the NSDistributedLock class

NSDistributedLock : NSObject

Declared in:
Foundation/NSDistributedLock.h
Standards:

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;

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


breakLock 

- (void) breakLock;

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;

Initialises the reciever 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;

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


tryLock 

- (BOOL) tryLock;

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


unlock 

- (void) unlock;

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;

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;

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