Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
CPExclusiveLock - iPhone Development Wiki

CPExclusiveLock

From iPhone Development Wiki
Revision as of 16:13, 26 October 2014 by Uroboro (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

CPExclusiveLock provides system-wide locking through temporary files. You use CPExclusiveLock like any other NSLocking-conformant classes.

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.

External links