Mercurial > projects > dstep
comparison dstep/foundation/NSDistributedLock.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 7ff919f595d5 |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSDistributedLock; | |
8 | |
9 import dstep.foundation.NSDate; | |
10 import dstep.foundation.NSObject; | |
11 import dstep.objc.bridge.Bridge; | |
12 import dstep.objc.objc : id; | |
13 | |
14 class NSDistributedLock : NSObject | |
15 { | |
16 mixin ObjcWrap; | |
17 | |
18 static NSDistributedLock lockWithPath (NSString path) | |
19 { | |
20 return invokeObjcSelfClass!(NSDistributedLock, "lockWithPath:", NSString)(pathreturn result is this.objcObject ? this : (result !is null ? new NSDistributedLock(result) : null); } | |
21 | |
22 Object initWithPath (NSString path) | |
23 { | |
24 return invokeObjcSelf!(Object, "initWithPath:", NSString)(path); | |
25 } | |
26 | |
27 this (NSString path) | |
28 { | |
29 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
30 id result = Bridge.invokeObjcMethod!(id, "initWithPath:", NSString)(objcObject, path); | |
31 | |
32 if (result) | |
33 objcObject = ret; | |
34 | |
35 dObject = this; | |
36 } | |
37 | |
38 bool tryLock () | |
39 { | |
40 return invokeObjcSelf!(bool, "tryLock"); | |
41 } | |
42 | |
43 void unlock () | |
44 { | |
45 return invokeObjcSelf!(void, "unlock"); | |
46 } | |
47 | |
48 void breakLock () | |
49 { | |
50 return invokeObjcSelf!(void, "breakLock"); | |
51 } | |
52 | |
53 NSDate lockDate () | |
54 { | |
55 return invokeObjcSelf!(NSDate, "lockDate"); | |
56 } | |
57 } | |
58 |