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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
13 package org.simantics.utils.threads.ua;
\r
15 import java.util.EnumSet;
\r
20 * Initial state: Active
\r
21 * Final state: Shutdown
\r
23 * State transitions:
\r
24 * -> Active -> Paused -> Active ->
\r
25 * -> Paused -> Closed -> Shutdown
\r
26 * -> Active -> Closed -> Shutdown
\r
28 * @author Toni Kalajainen (toni.kalajainen@vtt.fi)
\r
30 public enum ExecutorState {
\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
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