]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/IModificationQueue.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / IModificationQueue.java
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.diagram.synchronization;\r
13 \r
14 import org.simantics.utils.threads.IThreadWorkQueue;\r
15 \r
16 /**\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
19  * \r
20  * @author Tuukka Lehtonen\r
21  */\r
22 public interface IModificationQueue {\r
23 \r
24     /**\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
31      * \r
32      * <p>\r
33      * This method should be equal to calling\r
34      * {@link #offer(IModification, IThreadWorkQueue)} with a null\r
35      * IThreadWorkQueue argument.\r
36      * \r
37      * @param m the modification to execute\r
38      * @return <code>true</code> if the modification was added to the queue\r
39      */\r
40     boolean offer(IModification m);\r
41 \r
42     /**\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
49      * \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
53      *        about the thread.\r
54      * @return <code>true</code> if the modification was added to the queue\r
55      */\r
56     boolean offer(IModification m, IThreadWorkQueue completionThread);\r
57 \r
58     /**\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
62      */\r
63     void flush();\r
64 \r
65     /**\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
68      * \r
69      * @throws InterruptedException if the waiting thread is interrupted\r
70      */\r
71     void finish() throws InterruptedException;\r
72 \r
73 }\r