1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.synchronization;
14 import org.simantics.db.WriteGraph;
15 import org.simantics.utils.threads.IThreadWorkQueue;
16 import org.simantics.utils.threads.ThreadUtils;
19 * @author Tuukka Lehtonen
21 public class ThreadingModificationProxy extends ModificationAdapter {
22 private final IModification m;
23 private final IThreadWorkQueue completionThread;
24 private final boolean syncCompletion;
26 public ThreadingModificationProxy(IModification m, IThreadWorkQueue completionThread, boolean syncCompletion) {
27 super(m.getPriority());
29 this.completionThread = completionThread;
30 this.syncCompletion = syncCompletion;
33 public void completed() {
34 if (completionThread != null) {
35 Runnable r = new Runnable() {
42 ThreadUtils.syncExec(completionThread, r);
44 ThreadUtils.asyncExec(completionThread, r);
50 public boolean isComplete() {
51 return m.isComplete();
54 public void markComplete() {
58 public void perform(WriteGraph g) throws Exception {
62 public Throwable getException() {
63 return m.getException();
66 public void setException(Throwable t) {
70 public String toString() {
71 return getClass().getSimpleName() + "[" + m + "]";