changeset 101:58014b95afb5

Implemented RunnableLock. Thanks torhu for the testcase.
author Frank Benoit <benoit@tionex.de>
date Sat, 09 Feb 2008 21:29:43 +0100
parents 8e89c07402e9
children 40c02ead0a2c
files dwt/widgets/RunnableLock.d
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/widgets/RunnableLock.d	Sat Feb 09 21:26:08 2008 +0100
+++ b/dwt/widgets/RunnableLock.d	Sat Feb 09 21:29:43 2008 +0100
@@ -15,6 +15,8 @@
 import tango.core.Thread;
 import dwt.dwthelper.Runnable;
 import tango.core.Exception;
+import tango.core.sync.Condition;
+import tango.core.sync.Mutex;
 
 /**
  * Instances of this class are used to ensure that an
@@ -23,13 +25,15 @@
  * between widgets and background threads.
  */
 
-class RunnableLock  {
+class RunnableLock : Mutex {
     Runnable runnable;
     Thread thread;
     Exception throwable;
+    Condition cond;
 
 this (Runnable runnable) {
     this.runnable = runnable;
+    this.cond = new Condition(this);
 }
 
 bool done () {
@@ -41,11 +45,11 @@
     runnable = null;
 }
 
-//PORTING_FIXME: How to emulate Java locking?
 void notifyAll(){
+    cond.notifyAll();
 }
-//PORTING_FIXME: How to emulate Java locking?
 void wait(){
+    cond.wait();
 }
 
 }