--- /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
+\r
+package org.simantics.utils.threads.ua;\r
+\r
+\r
+/**\r
+ * Asynchronous work monitor object.\r
+ * \r
+ * @author Toni Kalajainen (toni.kalajainen@vtt.fi)\r
+ */\r
+public interface WorkMonitor extends IStatefulObject<WorkState, RuntimeException> {\r
+\r
+ /**\r
+ * Get the command\r
+ * \r
+ * @return runnable instance of the work\r
+ */\r
+ Runnable getRunnable();\r
+ \r
+ /**\r
+ * Attempts to cancel execution of this task. This attempt will\r
+ * fail if the task has already completed, has already been cancelled,\r
+ * or could not be cancelled for some other reason. If successful,\r
+ * and this task has not started when <tt>cancel</tt> is called,\r
+ * this task should never run. If the task has already started,\r
+ * then the <tt>mayInterruptIfRunning</tt> parameter determines\r
+ * whether the thread executing this task should be interrupted in\r
+ * an attempt to stop the task.\r
+ *\r
+ * <p>After this method returns, subsequent calls to {@link #isDone} will\r
+ * always return <tt>true</tt>. Subsequent calls to {@link #isCancelled}\r
+ * will always return <tt>true</tt> if this method returned <tt>true</tt>.\r
+ *\r
+ * @param mayInterruptIfRunning <tt>true</tt> if the thread executing this\r
+ * task should be interrupted; otherwise, in-progress tasks are allowed\r
+ * to complete\r
+ * @return <tt>false</tt> if the task could not be cancelled,\r
+ * typically because it has already completed normally;\r
+ * <tt>true</tt> otherwise\r
+ */\r
+ boolean cancel(boolean mayInterruptIfRunning);\r
+\r
+ /**\r
+ * Get error that occured during execution of the runnable.\r
+ * @return run-time exception\r
+ */\r
+ RuntimeException getError();\r
+ \r
+}\r