--- /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
+import java.util.EnumSet;\r
+\r
+/**\r
+ * State of a worker\r
+ * \r
+ * Initial state: Active\r
+ * Final state: Shutdown\r
+ * \r
+ * State transitions: \r
+ * -> Active -> Paused -> Active -> \r
+ * -> Paused -> Closed -> Shutdown \r
+ * -> Active -> Closed -> Shutdown\r
+ * \r
+ * @author Toni Kalajainen (toni.kalajainen@vtt.fi)\r
+ */\r
+public enum ExecutorState {\r
+ \r
+ Active, // Accepts and executes work. (Initial State)\r
+ Paused, // Accepts new work and but does not execute work from queues.\r
+ Shutdown, // Does not accept new work but executes remaining queues. Shifts to Terminated state automatically when queue is empty. \r
+ Terminated; // All threads are released and work queues are empty. Does not accept new work. (Final State)\r
+\r
+ public static EnumSet<ExecutorState> WORKING_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Shutdown);\r
+ public static EnumSet<ExecutorState> ACCEPTS_WORK_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Paused);\r
+ public static EnumSet<ExecutorState> FINAL_STATES = EnumSet.of(ExecutorState.Terminated);\r
+ public static EnumSet<ExecutorState> NON_PAUSED_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Shutdown, ExecutorState.Terminated);\r
+ \r
+}\r