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.utils.threads.IThreadWorkQueue;
17 * An abstraction for a queue of modifications to be performed into a backend
18 * model for synchronization with the diagram model.
20 * @author Tuukka Lehtonen
22 public interface IModificationQueue {
25 * Asynchronously perform the specified modification, using the specified
26 * thread for the modification completion event. This method will <b>not</b>
27 * cause any write request invocations to the backend, it merely offers the
28 * modifications up for execution. After several modifications have been
29 * offered, {@link #flush()} may be invoked to execute the offered
30 * modifications to execute multiple modifications in one transaction.
33 * This method should be equal to calling
34 * {@link #offer(IModification, IThreadWorkQueue)} with a null
35 * IThreadWorkQueue argument.
37 * @param m the modification to execute
38 * @return <code>true</code> if the modification was added to the queue
40 boolean offer(IModification m);
43 * Asynchronously perform the specified modification, using the specified
44 * thread for the modification completion event. This method will <b>not</b>
45 * cause any write request invocations to the backend, it merely offers the
46 * modifications up for execution. After several modifications have been
47 * offered, {@link #flush()} may be invoked to execute the offered
48 * modifications to execute multiple modifications in one transaction.
50 * @param m the modification to execute
51 * @param completionThread the thread to be used for running the
52 * modification completion event or <code>null</code> to not care
54 * @return <code>true</code> if the modification was added to the queue
56 boolean offer(IModification m, IThreadWorkQueue completionThread);
59 * Flushes the queue of modifications. All modifications shall be dispatched
60 * to be executed but this method can return at any time before the
61 * modifications have been performed.
66 * Finishes the queue of modifications gathered so far. This method will
67 * block until all current modifications have been ran to completion.
69 * @throws InterruptedException if the waiting thread is interrupted
71 void finish() throws InterruptedException;