]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/ExecutorState.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / ua / ExecutorState.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12
13 package org.simantics.utils.threads.ua;
14
15 import java.util.EnumSet;
16
17 /**
18  * State of a worker
19  * 
20  * Initial state: Active
21  * Final state: Shutdown
22  * 
23  * State transitions: 
24  *   -> Active -> Paused -> Active -> 
25  *   -> Paused -> Closed -> Shutdown 
26  *   -> Active -> Closed -> Shutdown
27  * 
28  * @author Toni Kalajainen (toni.kalajainen@vtt.fi)
29  */
30 public enum ExecutorState {
31         
32         Active,         // Accepts and executes work. (Initial State)
33         Paused,         // Accepts new work and but does not execute work from queues.
34         Shutdown,       // Does not accept new work but executes remaining queues. Shifts to Terminated state automatically when queue is empty. 
35         Terminated;     // All threads are released and work queues are empty. Does not accept new work. (Final State)
36
37         public static EnumSet<ExecutorState> WORKING_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Shutdown);
38         public static EnumSet<ExecutorState> ACCEPTS_WORK_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Paused);
39         public static EnumSet<ExecutorState> FINAL_STATES = EnumSet.of(ExecutorState.Terminated);
40         public static EnumSet<ExecutorState> NON_PAUSED_STATES = EnumSet.of(ExecutorState.Active, ExecutorState.Shutdown, ExecutorState.Terminated);
41         
42 }