X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fsynchronization%2FIModificationQueue.java;fp=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fsynchronization%2FIModificationQueue.java;h=e43cd896d57ab24f37267610ae4638f438a144df;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/IModificationQueue.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/IModificationQueue.java new file mode 100644 index 000000000..e43cd896d --- /dev/null +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/IModificationQueue.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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.utils.threads.IThreadWorkQueue; + +/** + * An abstraction for a queue of modifications to be performed into a backend + * model for synchronization with the diagram model. + * + * @author Tuukka Lehtonen + */ +public interface IModificationQueue { + + /** + * Asynchronously perform the specified modification, using the specified + * thread for the modification completion event. This method will not + * cause any write request invocations to the backend, it merely offers the + * modifications up for execution. After several modifications have been + * offered, {@link #flush()} may be invoked to execute the offered + * modifications to execute multiple modifications in one transaction. + * + *

+ * This method should be equal to calling + * {@link #offer(IModification, IThreadWorkQueue)} with a null + * IThreadWorkQueue argument. + * + * @param m the modification to execute + * @return true if the modification was added to the queue + */ + boolean offer(IModification m); + + /** + * Asynchronously perform the specified modification, using the specified + * thread for the modification completion event. This method will not + * cause any write request invocations to the backend, it merely offers the + * modifications up for execution. After several modifications have been + * offered, {@link #flush()} may be invoked to execute the offered + * modifications to execute multiple modifications in one transaction. + * + * @param m the modification to execute + * @param completionThread the thread to be used for running the + * modification completion event or null to not care + * about the thread. + * @return true if the modification was added to the queue + */ + boolean offer(IModification m, IThreadWorkQueue completionThread); + + /** + * Flushes the queue of modifications. All modifications shall be dispatched + * to be executed but this method can return at any time before the + * modifications have been performed. + */ + void flush(); + + /** + * Finishes the queue of modifications gathered so far. This method will + * block until all current modifications have been ran to completion. + * + * @throws InterruptedException if the waiting thread is interrupted + */ + void finish() throws InterruptedException; + +}