1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.diagram.synchronization;
\r
14 import org.simantics.utils.threads.IThreadWorkQueue;
\r
17 * An abstraction for a queue of modifications to be performed into a backend
\r
18 * model for synchronization with the diagram model.
\r
20 * @author Tuukka Lehtonen
\r
22 public interface IModificationQueue {
\r
25 * Asynchronously perform the specified modification, using the specified
\r
26 * thread for the modification completion event. This method will <b>not</b>
\r
27 * cause any write request invocations to the backend, it merely offers the
\r
28 * modifications up for execution. After several modifications have been
\r
29 * offered, {@link #flush()} may be invoked to execute the offered
\r
30 * modifications to execute multiple modifications in one transaction.
\r
33 * This method should be equal to calling
\r
34 * {@link #offer(IModification, IThreadWorkQueue)} with a null
\r
35 * IThreadWorkQueue argument.
\r
37 * @param m the modification to execute
\r
38 * @return <code>true</code> if the modification was added to the queue
\r
40 boolean offer(IModification m);
\r
43 * Asynchronously perform the specified modification, using the specified
\r
44 * thread for the modification completion event. This method will <b>not</b>
\r
45 * cause any write request invocations to the backend, it merely offers the
\r
46 * modifications up for execution. After several modifications have been
\r
47 * offered, {@link #flush()} may be invoked to execute the offered
\r
48 * modifications to execute multiple modifications in one transaction.
\r
50 * @param m the modification to execute
\r
51 * @param completionThread the thread to be used for running the
\r
52 * modification completion event or <code>null</code> to not care
\r
54 * @return <code>true</code> if the modification was added to the queue
\r
56 boolean offer(IModification m, IThreadWorkQueue completionThread);
\r
59 * Flushes the queue of modifications. All modifications shall be dispatched
\r
60 * to be executed but this method can return at any time before the
\r
61 * modifications have been performed.
\r
66 * Finishes the queue of modifications gathered so far. This method will
\r
67 * block until all current modifications have been ran to completion.
\r
69 * @throws InterruptedException if the waiting thread is interrupted
\r
71 void finish() throws InterruptedException;
\r