NSDistributedLock |
Mac OS X 10.0 |
This class provides an interface to an
object that can be used by
multiple applications to control access to a shared resource (such as
a file). This class works by creating an entry in the filesystem at a
path known to each application that is interested in acquiring a lock
to access the shared resource.
A distributed lock object is initialized
with a filesystem entry using the method
initWithPath:. To acquire a lock, thus making it
safe to access a resource, we use the method
tryLock. This method returns a
BOOL indicating whether or not it was successful
in attempting to acquire a lock. To relinquish a previously acquired
lock, use the method unlock.
@interface NSDistributedLock : NSObject
|
// Initializers |
- (id)initWithPath:(NSString *)path;
|
// Class Methods |
+ (NSDistributedLock *)lockWithPath:(NSString *)path;
|
// Instance Methods |
- (void)breakLock;
|
- (NSDate *)lockDate;
|
- (BOOL)tryLock;
|
- (void)unlock;
|
|