1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
13 package org.simantics.utils.threads.ua;
15 import java.util.EnumSet;
20 * Initial state: Active
21 * Final state: Shutdown
24 * -> Active -> Paused -> Active ->
25 * -> Paused -> Closed -> Shutdown
26 * -> Active -> Closed -> Shutdown
28 * @author Toni Kalajainen (toni.kalajainen@vtt.fi)
30 public enum ExecutorState {
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)
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);