CPExclusiveLock

From iPhone Development Wiki
Revision as of 16:57, 21 September 2009 by KennyTM~ (talk | contribs) (Created page with '{{occlass|library=AppSupport.framework}} CPExclusiveLock provides system-wise locking through temporary files. You use CPExclusiveLock like any other <code>NSLock</code>s, e…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


CPExclusiveLock provides system-wise locking through temporary files. You use CPExclusiveLock like any other NSLocks, e.g.

CPExclusiveLock* syslock = [[CPExclusiveLock alloc] initWithName:@"MyExclusiveLock"];
[syslock lock];
[device doOperation:1 :2 :3 :4];
[syslock unlock];

A CPExclusiveLock will create a temporary file in ~/Library/Caches. If the name is given, it will be used as the filename. When the lock is acquired, the object will open the temporary file with O_NONBLOCK|O_EXLOCK|O_CREAT mode.

Header