-/*******************************************************************************\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
-import java.util.EnumSet;\r
-\r
-/**\r
- * State of an async execution (=work)\r
- * \r
- * Initial states: Ready\r
- * Final states: Complete, Canceled, Error, Interrupted\r
- * \r
- * State transitions:\r
- * Ready -> Canceled\r
- * Ready -> Working -> Complete\r
- * Ready -> Working -> Error \r
- * Ready -> Working -> Interrupting -> Error\r
- * Ready -> Working -> Interrupting -> Interrupted\r
- * \r
- * @see WorkMonitor\r
- * @see Work\r
- * @see AsyncRun\r
- * @author Toni Kalajainen (toni.kalajainen@vtt.fi)\r
- */\r
-public enum WorkState {\r
-\r
- Ready, // Work has not been started. (Initial State)\r
- Working, // The work has started.\r
- Complete, // The work has completed. (Final State)\r
- Interrupting, // Interrupt signal has been sent.\r
- Interrupted, // The work was has ended after interrupt signal. (Final State)\r
- Error, // There was an error during the execution. (Final State)\r
- Canceled; // Work was canceled before it was started. (Final State)\r
- \r
- public static final EnumSet<WorkState> READY_STATE = EnumSet.of(WorkState.Ready);\r
- public static final EnumSet<WorkState> WORKING_STATE = EnumSet.of(WorkState.Working);\r
- public static final EnumSet<WorkState> FINAL_STATES = EnumSet.of(WorkState.Complete, WorkState.Error, WorkState.Canceled, WorkState.Interrupted);\r
- public static final EnumSet<WorkState> COMPLETE_STATE = EnumSet.of(WorkState.Complete);\r
- public static final EnumSet<WorkState> ERROR_STATE = EnumSet.of(WorkState.Error);\r
- public static final EnumSet<WorkState> CANCELED_STATE = EnumSet.of(WorkState.Canceled);\r
- public static final EnumSet<WorkState> CANCELED_STATES = EnumSet.of(WorkState.Canceled, WorkState.Interrupted, WorkState.Interrupting);\r
-\r
- public boolean isFinalState()\r
- {\r
- return FINAL_STATES.contains(this);\r
- }\r
- \r
- public boolean isInitialState()\r
- {\r
- return this == Ready;\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * 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.utils.threads.ua;
+
+import java.util.EnumSet;
+
+/**
+ * State of an async execution (=work)
+ *
+ * Initial states: Ready
+ * Final states: Complete, Canceled, Error, Interrupted
+ *
+ * State transitions:
+ * Ready -> Canceled
+ * Ready -> Working -> Complete
+ * Ready -> Working -> Error
+ * Ready -> Working -> Interrupting -> Error
+ * Ready -> Working -> Interrupting -> Interrupted
+ *
+ * @see WorkMonitor
+ * @see Work
+ * @see AsyncRun
+ * @author Toni Kalajainen (toni.kalajainen@vtt.fi)
+ */
+public enum WorkState {
+
+ Ready, // Work has not been started. (Initial State)
+ Working, // The work has started.
+ Complete, // The work has completed. (Final State)
+ Interrupting, // Interrupt signal has been sent.
+ Interrupted, // The work was has ended after interrupt signal. (Final State)
+ Error, // There was an error during the execution. (Final State)
+ Canceled; // Work was canceled before it was started. (Final State)
+
+ public static final EnumSet<WorkState> READY_STATE = EnumSet.of(WorkState.Ready);
+ public static final EnumSet<WorkState> WORKING_STATE = EnumSet.of(WorkState.Working);
+ public static final EnumSet<WorkState> FINAL_STATES = EnumSet.of(WorkState.Complete, WorkState.Error, WorkState.Canceled, WorkState.Interrupted);
+ public static final EnumSet<WorkState> COMPLETE_STATE = EnumSet.of(WorkState.Complete);
+ public static final EnumSet<WorkState> ERROR_STATE = EnumSet.of(WorkState.Error);
+ public static final EnumSet<WorkState> CANCELED_STATE = EnumSet.of(WorkState.Canceled);
+ public static final EnumSet<WorkState> CANCELED_STATES = EnumSet.of(WorkState.Canceled, WorkState.Interrupted, WorkState.Interrupting);
+
+ public boolean isFinalState()
+ {
+ return FINAL_STATES.contains(this);
+ }
+
+ public boolean isInitialState()
+ {
+ return this == Ready;
+ }
+
+}