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: Difference between revisions - iPhone Development Wiki

CPExclusiveLock: Difference between revisions

From iPhone Development Wiki
(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…')
 
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{occlass|library=AppSupport.framework}}
[[CPExclusiveLock]] provides system-wide locking through temporary files. You use CPExclusiveLock like any other <code>NSLocking</code>-conformant classes.


[[CPExclusiveLock]] provides system-wise locking through temporary files. You use CPExclusiveLock like any other <code>NSLock</code>s, e.g.
<source lang="objc">
<source lang="objc">
CPExclusiveLock* syslock = [[CPExclusiveLock alloc] initWithName:@"MyExclusiveLock"];
CPExclusiveLock* syslock = [[CPExclusiveLock alloc] initWithName:@"MyExclusiveLock"];
Line 12: Line 11:
When the lock is acquired, the object will open the temporary file with <code>O_NONBLOCK|O_EXLOCK|O_CREAT</code> mode.
When the lock is acquired, the object will open the temporary file with <code>O_NONBLOCK|O_EXLOCK|O_CREAT</code> mode.


== Header ==
== External links ==
* http://github.com/kennytm/iphone-private-frameworks/blob/master/AppSupport/CPExclusiveLock.h
 
{{IPFHeader|AppSupport}}

Latest revision as of 16:13, 26 October 2014

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