]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/ExecutorState.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / ua / ExecutorState.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 \r
13 package org.simantics.utils.threads.ua;\r
14 \r
15 import java.util.EnumSet;\r
16 \r
17 /**\r
18  * State of a worker\r
19  * \r
20  * Initial state: Active\r
21  * Final state: Shutdown\r
22  * \r
23  * State transitions: \r
24  *   -> Active -> Paused -> Active -> \r
25  *   -> Paused -> Closed -> Shutdown \r
26  *   -> Active -> Closed -> Shutdown\r
27  * \r
28  * @author Toni Kalajainen (toni.kalajainen@vtt.fi)\r
29  */\r
30 public enum ExecutorState {\r
31         \r
32         Active,         // Accepts and executes work. (Initial State)\r
33         Paused,         // Accepts new work and but does not execute work from queues.\r
34         Shutdown,       // Does not accept new work but executes remaining queues. Shifts to Terminated state automatically when queue is empty. \r
35         Terminated;     // All threads are released and work queues are empty. Does not accept new work. (Final State)\r
36 \r
37         public static EnumSet<ExecutorState> WORKING_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Shutdown);\r
38         public static EnumSet<ExecutorState> ACCEPTS_WORK_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Paused);\r
39         public static EnumSet<ExecutorState> FINAL_STATES = EnumSet.of(ExecutorState.Terminated);\r
40         public static EnumSet<ExecutorState> NON_PAUSED_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Shutdown, ExecutorState.Terminated);\r
41         \r
42 }\r