Mercurial > projects > dwt2
diff org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/Lock.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 | 0ecb2b338560 |
children |
line wrap: on
line diff
--- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/Lock.d Wed Mar 16 21:53:53 2011 +0900 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/Lock.d Wed Apr 06 21:57:23 2011 +0200 @@ -17,7 +17,9 @@ version(Tango){ import tango.core.sync.Mutex; import tango.core.sync.Condition; -} else { // Phobos +} else { + import core.sync.mutex; + import core.sync.condition; } /** @@ -26,19 +28,12 @@ public class Lock { int count, waitCount; Thread owner; - version(Tango){ - Mutex mutex; - Condition cond; - } else { // Phobos - } - + Mutex mutex; + Condition cond; public this() { - version(Tango){ - mutex = new Mutex; - cond = new Condition(mutex); - } else { // Phobos - } + mutex = new Mutex; + cond = new Condition(mutex); } /** * Locks the monitor and returns the lock count. If @@ -48,26 +43,21 @@ * @return the lock count */ public int lock() { - version(Tango){ - synchronized (mutex) { - Thread current = Thread.currentThread(); - if (owner !is current) { - waitCount++; - while (count > 0) { - try { - cond.wait(); - } catch (SyncException e) { - /* Wait forever, just like synchronized blocks */ - } + synchronized (mutex) { + Thread current = Thread.currentThread(); + if (owner !is current) { + waitCount++; + while (count > 0) { + try { + cond.wait(); + } catch (SyncException e) { + /* Wait forever, just like synchronized blocks */ } - --waitCount; - owner = current; } - return ++count; + --waitCount; + owner = current; } - } else { // Phobos - implMissing( __FILE__, __LINE__ ); - return 0; + return ++count; } } @@ -76,18 +66,14 @@ * the monitor owner, do nothing. */ public void unlock() { - version(Tango){ - synchronized (mutex) { - Thread current = Thread.currentThread(); - if (owner is current) { - if (--count is 0) { - owner = null; - if (waitCount > 0) cond.notifyAll(); - } + synchronized (mutex) { + Thread current = Thread.currentThread(); + if (owner is current) { + if (--count is 0) { + owner = null; + if (waitCount > 0) cond.notifyAll(); } } - } else { // Phobos - implMissing( __FILE__, __LINE__ ); } } }