view dwt/widgets/RunnableLock.d @ 15:2952d5604c0a

Ported some widgets, added some stuff to the runtime bindings
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 29 Aug 2008 21:46:05 +0200
parents 380af2bdd8e5
children 5b53d338c709
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2000, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     
 * Port to the D programming language:
 *     Jacob Carlborg <jacob.carlborg@gmail.com>
 *******************************************************************************/
module dwt.widgets.RunnableLock;

import tango.core.Thread;

import dwt.dwthelper.Runnable;
import dwt.dwthelper.utils;


/**
 * Instances of this class are used to ensure that an
 * application cannot interfere with the locking mechanism
 * used to implement asynchronous and synchronous communication
 * between widgets and background threads.
 */

class RunnableLock {
    Runnable runnable;
    Thread thread;
    Throwable throwable;
    
this (Runnable runnable) {
    this.runnable = runnable;
}

bool done () {
    return runnable is null || throwable !is null;
}

void run () {
    if (runnable !is null) runnable.run ();
    runnable = null;
}

}