Mercurial > projects > dwt2
annotate org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/RunnableLock.d @ 47:65761bc28ab2
swt linux again compilable for d1.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 11:43:53 +0100 |
parents | f713da8bc051 |
children | ddbfe84d86df |
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; |
25 | 18 import tango.core.Exception; |
19 import tango.core.sync.Condition; | |
20 import tango.core.sync.Mutex; | |
21 | |
22 /** | |
23 * Instances of this class are used to ensure that an | |
24 * application cannot interfere with the locking mechanism | |
25 * used to implement asynchronous and synchronous communication | |
26 * between widgets and background threads. | |
27 */ | |
28 | |
29 class RunnableLock : Mutex { | |
30 Runnable runnable; | |
31 Thread thread; | |
32 Exception throwable; | |
33 | |
34 Condition cond; | |
35 | |
36 this (Runnable runnable) { | |
37 this.runnable = runnable; | |
38 this.cond = new Condition(this); | |
39 } | |
40 | |
41 bool done () { | |
42 return runnable is null || throwable !is null; | |
43 } | |
44 | |
45 void run () { | |
46 if (runnable !is null) runnable.run (); | |
47 runnable = null; | |
48 } | |
49 | |
50 void notifyAll(){ | |
51 cond.notifyAll(); | |
52 } | |
53 void wait(){ | |
54 cond.wait(); | |
55 } | |
56 | |
57 } |