comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/RunnableLock.d @ 38:2e09b0e6857a

work on phobosfication
author Frank Benoit <benoit@tionex.de>
date Wed, 25 Mar 2009 11:18:25 +0100
parents 52184e4b815c
children 9f4c18c268b2
comparison
equal deleted inserted replaced
37:46c5f8f56b41 38:2e09b0e6857a
12 *******************************************************************************/ 12 *******************************************************************************/
13 module org.eclipse.swt.widgets.RunnableLock; 13 module org.eclipse.swt.widgets.RunnableLock;
14 14
15 import java.lang.all; 15 import java.lang.all;
16 import java.lang.Thread; 16 import java.lang.Thread;
17 import tango.core.sync.Condition; 17 version(Tango){
18 import tango.core.sync.Mutex; 18 import tango.core.sync.Condition;
19 import tango.core.sync.Mutex;
20 } else { // Phobos
21 alias Object Mutex; //FIXME, this is just a dummy because of Mutex missing
22 }
19 23
20 /** 24 /**
21 * Instances of this class are used to ensure that an 25 * Instances of this class are used to ensure that an
22 * application cannot interfere with the locking mechanism 26 * application cannot interfere with the locking mechanism
23 * used to implement asynchronous and synchronous communication 27 * used to implement asynchronous and synchronous communication
26 30
27 class RunnableLock : Mutex { 31 class RunnableLock : Mutex {
28 Runnable runnable; 32 Runnable runnable;
29 Thread thread; 33 Thread thread;
30 Exception throwable; 34 Exception throwable;
31 Condition cond; 35 version(Tango){
36 Condition cond;
37 } else { // Phobos
38 }
32 39
33 this (Runnable runnable) { 40 this (Runnable runnable) {
34 this.runnable = runnable; 41 this.runnable = runnable;
35 this.cond = new Condition(this); 42 version(Tango){
36 } 43 this.cond = new Condition(this);
44 } else { // Phobos
45 implMissing( __FILE__, __LINE__ );
46 }
47 }
37 48
38 bool done () { 49 bool done () {
39 return runnable is null || throwable !is null; 50 return runnable is null || throwable !is null;
40 } 51 }
41 52
42 void run () { 53 void run () {
43 if (runnable !is null) runnable.run (); 54 if (runnable !is null) runnable.run ();
44 runnable = null; 55 runnable = null;
45 } 56 }
46 57
47 void notifyAll(){ 58 void notifyAll(){
48 cond.notifyAll(); 59 version(Tango){
49 } 60 cond.notifyAll();
50 void wait(){ 61 } else { // Phobos
51 cond.wait(); 62 implMissing( __FILE__, __LINE__ );
52 } 63 }
64 }
65 void wait(){
66 version(Tango){
67 cond.wait();
68 } else { // Phobos
69 implMissing( __FILE__, __LINE__ );
70 }
71 }
53 72
54 } 73 }