X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils.thread%2Fsrc%2Forg%2Fsimantics%2Futils%2Fthreads%2FExecutors2.java;h=66af9794b3841426ce446ea0d9e304442b013ad7;hb=fbe4ffbf25e0b35dcbd51f11b50e740bfe4c593d;hp=35171b95b5e5fead72d5a1ba94617d138c5acab4;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/Executors2.java b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/Executors2.java index 35171b95b..66af9794b 100644 --- a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/Executors2.java +++ b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/Executors2.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.utils.threads; - -import java.util.concurrent.Executor; - -import org.eclipse.swt.widgets.Display; - -public class Executors2 { - - public static Executor createSWTExecutor(Display display, boolean async) { - return async ? new SWTExecutorAsync(display) : new SWTExecutorSync(display); - } - -} - -class SWTExecutorAsync implements Executor { - - Display display; - public SWTExecutorAsync(Display display) - { - this.display = display; - } - - @Override - public void execute(Runnable command) { - // Don't accept work if the SWT thread is disposed. - if (display.isDisposed()) - throw new RuntimeException("The SWT thread has been disposed"); - display.asyncExec(command); - } - -} - -class SWTExecutorSync implements Executor { - - Display display; - public SWTExecutorSync(Display display) - { - this.display = display; - } - - @Override - public void execute(Runnable command) { - // Don't accept work if the SWT thread is disposed. - if (display.isDisposed()) - throw new RuntimeException("The SWT thread has been disposed"); - display.syncExec(command); - } - -} - +/******************************************************************************* + * Copyright (c) 2007 VTT Technical Research Centre of Finland 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: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.utils.threads; + +import java.util.concurrent.Executor; + +import org.eclipse.swt.widgets.Display; + +public class Executors2 { + + public static Executor createSWTExecutor(Display display, boolean async) { + return async ? new SWTExecutorAsync(display) : new SWTExecutorSync(display); + } + +} + +class SWTExecutorAsync implements Executor { + + Display display; + public SWTExecutorAsync(Display display) + { + this.display = display; + } + + @Override + public void execute(Runnable command) { + // Don't accept work if the SWT thread is disposed. + if (display.isDisposed()) + throw new RuntimeException("The SWT thread has been disposed"); + display.asyncExec(command); + } + +} + +class SWTExecutorSync implements Executor { + + Display display; + public SWTExecutorSync(Display display) + { + this.display = display; + } + + @Override + public void execute(Runnable command) { + // Don't accept work if the SWT thread is disposed. + if (display.isDisposed()) + throw new RuntimeException("The SWT thread has been disposed"); + display.syncExec(command); + } + +} +