Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/RunnableLock.d @ 113:fb3aa8075988
D2 support for the linux port.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Wed, 06 Apr 2011 21:57:23 +0200 |
parents | 7a2dd761a8b2 |
children |
comparison
equal
deleted
inserted
replaced
112:9f4c18c268b2 | 113:fb3aa8075988 |
---|---|
17 import java.lang.Thread; | 17 import java.lang.Thread; |
18 version(Tango){ | 18 version(Tango){ |
19 import tango.core.sync.Condition; | 19 import tango.core.sync.Condition; |
20 import tango.core.sync.Mutex; | 20 import tango.core.sync.Mutex; |
21 } else { // Phobos | 21 } else { // Phobos |
22 alias Object Mutex; // FIXME, real mutex is needed | 22 import core.sync.condition; |
23 import core.sync.mutex; | |
23 } | 24 } |
24 | 25 |
25 /** | 26 /** |
26 * Instances of this class are used to ensure that an | 27 * Instances of this class are used to ensure that an |
27 * application cannot interfere with the locking mechanism | 28 * application cannot interfere with the locking mechanism |
32 class RunnableLock : Mutex { | 33 class RunnableLock : Mutex { |
33 Runnable runnable; | 34 Runnable runnable; |
34 Thread thread; | 35 Thread thread; |
35 Exception throwable; | 36 Exception throwable; |
36 | 37 |
37 version(Tango){ | 38 Condition cond; |
38 Condition cond; | |
39 } else { // Phobos | |
40 } | |
41 | 39 |
42 this (Runnable runnable) { | 40 this (Runnable runnable) { |
43 this.runnable = runnable; | 41 this.runnable = runnable; |
44 version(Tango){ | 42 this.cond = new Condition(this); |
45 this.cond = new Condition(this); | |
46 } else { // Phobos | |
47 implMissing(__FILE__, __LINE__); | |
48 } | |
49 } | 43 } |
50 | 44 |
51 bool done () { | 45 bool done () { |
52 return runnable is null || throwable !is null; | 46 return runnable is null || throwable !is null; |
53 } | 47 } |
56 if (runnable !is null) runnable.run (); | 50 if (runnable !is null) runnable.run (); |
57 runnable = null; | 51 runnable = null; |
58 } | 52 } |
59 | 53 |
60 void notifyAll(){ | 54 void notifyAll(){ |
61 version(Tango){ | 55 cond.notifyAll(); |
62 cond.notifyAll(); | |
63 } else { // Phobos | |
64 implMissing(__FILE__, __LINE__); | |
65 } | |
66 } | 56 } |
67 void wait(){ | 57 void wait(){ |
68 version(Tango){ | 58 cond.wait(); |
69 cond.wait(); | |
70 } else { // Phobos | |
71 implMissing(__FILE__, __LINE__); | |
72 } | |
73 } | 59 } |
74 | 60 |
75 } | 61 } |