-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.diagram.synchronization;\r
-\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.utils.threads.IThreadWorkQueue;\r
-import org.simantics.utils.threads.ThreadUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ThreadingModificationProxy extends ModificationAdapter {\r
- private final IModification m;\r
- private final IThreadWorkQueue completionThread;\r
- private final boolean syncCompletion;\r
-\r
- public ThreadingModificationProxy(IModification m, IThreadWorkQueue completionThread, boolean syncCompletion) {\r
- super(m.getPriority());\r
- this.m = m;\r
- this.completionThread = completionThread;\r
- this.syncCompletion = syncCompletion;\r
- }\r
- @Override\r
- public void completed() {\r
- if (completionThread != null) {\r
- Runnable r = new Runnable() {\r
- @Override\r
- public void run() {\r
- m.completed();\r
- }\r
- };\r
- if (syncCompletion)\r
- ThreadUtils.syncExec(completionThread, r);\r
- else\r
- ThreadUtils.asyncExec(completionThread, r);\r
- } else {\r
- m.completed();\r
- }\r
- }\r
- @Override\r
- public boolean isComplete() {\r
- return m.isComplete();\r
- }\r
- @Override\r
- public void markComplete() {\r
- m.markComplete();\r
- }\r
- @Override\r
- public void perform(WriteGraph g) throws Exception {\r
- m.perform(g);\r
- }\r
- @Override\r
- public Throwable getException() {\r
- return m.getException();\r
- }\r
- @Override\r
- public void setException(Throwable t) {\r
- m.setException(t);\r
- }\r
- @Override\r
- public String toString() {\r
- return getClass().getSimpleName() + "[" + m + "]";\r
- }\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * 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.diagram.synchronization;
+
+import org.simantics.db.WriteGraph;
+import org.simantics.utils.threads.IThreadWorkQueue;
+import org.simantics.utils.threads.ThreadUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ThreadingModificationProxy extends ModificationAdapter {
+ private final IModification m;
+ private final IThreadWorkQueue completionThread;
+ private final boolean syncCompletion;
+
+ public ThreadingModificationProxy(IModification m, IThreadWorkQueue completionThread, boolean syncCompletion) {
+ super(m.getPriority());
+ this.m = m;
+ this.completionThread = completionThread;
+ this.syncCompletion = syncCompletion;
+ }
+ @Override
+ public void completed() {
+ if (completionThread != null) {
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ m.completed();
+ }
+ };
+ if (syncCompletion)
+ ThreadUtils.syncExec(completionThread, r);
+ else
+ ThreadUtils.asyncExec(completionThread, r);
+ } else {
+ m.completed();
+ }
+ }
+ @Override
+ public boolean isComplete() {
+ return m.isComplete();
+ }
+ @Override
+ public void markComplete() {
+ m.markComplete();
+ }
+ @Override
+ public void perform(WriteGraph g) throws Exception {
+ m.perform(g);
+ }
+ @Override
+ public Throwable getException() {
+ return m.getException();
+ }
+ @Override
+ public void setException(Throwable t) {
+ m.setException(t);
+ }
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[" + m + "]";
+ }
}
\ No newline at end of file