Mercurial > projects > dstep
annotate dstep/foundation/NSDistributedLock.d @ 15:7ff919f595d5
Added the Foundation framework, again
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:31:48 +0200 |
parents | 89f3c3ef1fd2 |
children | 19885b43130e |
rev | line source |
---|---|
14 | 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 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
20 return invokeObjcSelfClass!(NSDistributedLock, "lockWithPath:", NSString)(path); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
21 } |
14 | 22 |
23 Object initWithPath (NSString path) | |
24 { | |
25 return invokeObjcSelf!(Object, "initWithPath:", NSString)(path); | |
26 } | |
27 | |
28 this (NSString path) | |
29 { | |
30 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
31 id result = Bridge.invokeObjcMethod!(id, "initWithPath:", NSString)(objcObject, path); | |
32 | |
33 if (result) | |
34 objcObject = ret; | |
35 | |
36 dObject = this; | |
37 } | |
38 | |
39 bool tryLock () | |
40 { | |
41 return invokeObjcSelf!(bool, "tryLock"); | |
42 } | |
43 | |
44 void unlock () | |
45 { | |
46 return invokeObjcSelf!(void, "unlock"); | |
47 } | |
48 | |
49 void breakLock () | |
50 { | |
51 return invokeObjcSelf!(void, "breakLock"); | |
52 } | |
53 | |
54 NSDate lockDate () | |
55 { | |
56 return invokeObjcSelf!(NSDate, "lockDate"); | |
57 } | |
58 } | |
59 |