Mercurial > projects > dwt2
annotate 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 |
rev | line source |
---|---|
25 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.widgets.RunnableLock; | |
14 | |
15 import java.lang.all; | |
16 | |
47
65761bc28ab2
swt linux again compilable for d1.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
17 import java.lang.Thread; |
48 | 18 version(Tango){ |
49
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
19 import tango.core.sync.Condition; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
20 import tango.core.sync.Mutex; |
48 | 21 } else { // Phobos |
113 | 22 import core.sync.condition; |
23 import core.sync.mutex; | |
48 | 24 } |
25 | 25 |
26 /** | |
27 * Instances of this class are used to ensure that an | |
28 * application cannot interfere with the locking mechanism | |
29 * used to implement asynchronous and synchronous communication | |
30 * between widgets and background threads. | |
31 */ | |
32 | |
33 class RunnableLock : Mutex { | |
34 Runnable runnable; | |
35 Thread thread; | |
36 Exception throwable; | |
37 | |
113 | 38 Condition cond; |
25 | 39 |
40 this (Runnable runnable) { | |
41 this.runnable = runnable; | |
113 | 42 this.cond = new Condition(this); |
25 | 43 } |
44 | |
45 bool done () { | |
46 return runnable is null || throwable !is null; | |
47 } | |
48 | |
49 void run () { | |
50 if (runnable !is null) runnable.run (); | |
51 runnable = null; | |
52 } | |
53 | |
54 void notifyAll(){ | |
113 | 55 cond.notifyAll(); |
25 | 56 } |
57 void wait(){ | |
113 | 58 cond.wait(); |
25 | 59 } |
60 | |
61 } |