--- /dev/null
+/*******************************************************************************\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.utils.threads.IThreadWorkQueue;\r
+\r
+/**\r
+ * An abstraction for a queue of modifications to be performed into a backend\r
+ * model for synchronization with the diagram model.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public interface IModificationQueue {\r
+\r
+ /**\r
+ * Asynchronously perform the specified modification, using the specified\r
+ * thread for the modification completion event. This method will <b>not</b>\r
+ * cause any write request invocations to the backend, it merely offers the\r
+ * modifications up for execution. After several modifications have been\r
+ * offered, {@link #flush()} may be invoked to execute the offered\r
+ * modifications to execute multiple modifications in one transaction.\r
+ * \r
+ * <p>\r
+ * This method should be equal to calling\r
+ * {@link #offer(IModification, IThreadWorkQueue)} with a null\r
+ * IThreadWorkQueue argument.\r
+ * \r
+ * @param m the modification to execute\r
+ * @return <code>true</code> if the modification was added to the queue\r
+ */\r
+ boolean offer(IModification m);\r
+\r
+ /**\r
+ * Asynchronously perform the specified modification, using the specified\r
+ * thread for the modification completion event. This method will <b>not</b>\r
+ * cause any write request invocations to the backend, it merely offers the\r
+ * modifications up for execution. After several modifications have been\r
+ * offered, {@link #flush()} may be invoked to execute the offered\r
+ * modifications to execute multiple modifications in one transaction.\r
+ * \r
+ * @param m the modification to execute\r
+ * @param completionThread the thread to be used for running the\r
+ * modification completion event or <code>null</code> to not care\r
+ * about the thread.\r
+ * @return <code>true</code> if the modification was added to the queue\r
+ */\r
+ boolean offer(IModification m, IThreadWorkQueue completionThread);\r
+\r
+ /**\r
+ * Flushes the queue of modifications. All modifications shall be dispatched\r
+ * to be executed but this method can return at any time before the\r
+ * modifications have been performed.\r
+ */\r
+ void flush();\r
+\r
+ /**\r
+ * Finishes the queue of modifications gathered so far. This method will\r
+ * block until all current modifications have been ran to completion.\r
+ * \r
+ * @throws InterruptedException if the waiting thread is interrupted\r
+ */\r
+ void finish() throws InterruptedException;\r
+\r
+}\r