comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/RunnableLock.d @ 0:6dd524f61e62

add dwt win and basic java stuff
author Frank Benoit <benoit@tionex.de>
date Mon, 02 Mar 2009 14:44:16 +0100
parents
children f36c67707cb3
comparison
equal deleted inserted replaced
-1:000000000000 0:6dd524f61e62
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 tango.core.Thread;
16 import java.lang.Runnable;
17 import tango.core.Exception;
18 import tango.core.sync.Condition;
19 import tango.core.sync.Mutex;
20
21 /**
22 * Instances of this class are used to ensure that an
23 * application cannot interfere with the locking mechanism
24 * used to implement asynchronous and synchronous communication
25 * between widgets and background threads.
26 */
27
28 class RunnableLock : Mutex {
29 Runnable runnable;
30 Thread thread;
31 Exception throwable;
32 Condition cond;
33
34 this (Runnable runnable) {
35 this.runnable = runnable;
36 this.cond = new Condition(this);
37 }
38
39 bool done () {
40 return runnable is null || throwable !is null;
41 }
42
43 void run () {
44 if (runnable !is null) runnable.run ();
45 runnable = null;
46 }
47
48 void notifyAll(){
49 cond.notifyAll();
50 }
51 void wait(){
52 cond.wait();
53 }
54
55 }