X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.utils.thread%2Fsrc%2Forg%2Fsimantics%2Futils%2Fthreads%2Fua%2FWorkState.java;h=e5904534174bffdad2dcc14b41416af516aa66ab;hb=refs%2Fchanges%2F38%2F238%2F2;hp=08d349c1aa7a5ab033242999dfb2c47be912056e;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/WorkState.java b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/WorkState.java index 08d349c1a..e59045341 100644 --- a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/WorkState.java +++ b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/WorkState.java @@ -1,63 +1,63 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ - -package org.simantics.utils.threads.ua; - -import java.util.EnumSet; - -/** - * State of an async execution (=work) - * - * Initial states: Ready - * Final states: Complete, Canceled, Error, Interrupted - * - * State transitions: - * Ready -> Canceled - * Ready -> Working -> Complete - * Ready -> Working -> Error - * Ready -> Working -> Interrupting -> Error - * Ready -> Working -> Interrupting -> Interrupted - * - * @see WorkMonitor - * @see Work - * @see AsyncRun - * @author Toni Kalajainen (toni.kalajainen@vtt.fi) - */ -public enum WorkState { - - Ready, // Work has not been started. (Initial State) - Working, // The work has started. - Complete, // The work has completed. (Final State) - Interrupting, // Interrupt signal has been sent. - Interrupted, // The work was has ended after interrupt signal. (Final State) - Error, // There was an error during the execution. (Final State) - Canceled; // Work was canceled before it was started. (Final State) - - public static final EnumSet READY_STATE = EnumSet.of(WorkState.Ready); - public static final EnumSet WORKING_STATE = EnumSet.of(WorkState.Working); - public static final EnumSet FINAL_STATES = EnumSet.of(WorkState.Complete, WorkState.Error, WorkState.Canceled, WorkState.Interrupted); - public static final EnumSet COMPLETE_STATE = EnumSet.of(WorkState.Complete); - public static final EnumSet ERROR_STATE = EnumSet.of(WorkState.Error); - public static final EnumSet CANCELED_STATE = EnumSet.of(WorkState.Canceled); - public static final EnumSet CANCELED_STATES = EnumSet.of(WorkState.Canceled, WorkState.Interrupted, WorkState.Interrupting); - - public boolean isFinalState() - { - return FINAL_STATES.contains(this); - } - - public boolean isInitialState() - { - return this == Ready; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ + +package org.simantics.utils.threads.ua; + +import java.util.EnumSet; + +/** + * State of an async execution (=work) + * + * Initial states: Ready + * Final states: Complete, Canceled, Error, Interrupted + * + * State transitions: + * Ready -> Canceled + * Ready -> Working -> Complete + * Ready -> Working -> Error + * Ready -> Working -> Interrupting -> Error + * Ready -> Working -> Interrupting -> Interrupted + * + * @see WorkMonitor + * @see Work + * @see AsyncRun + * @author Toni Kalajainen (toni.kalajainen@vtt.fi) + */ +public enum WorkState { + + Ready, // Work has not been started. (Initial State) + Working, // The work has started. + Complete, // The work has completed. (Final State) + Interrupting, // Interrupt signal has been sent. + Interrupted, // The work was has ended after interrupt signal. (Final State) + Error, // There was an error during the execution. (Final State) + Canceled; // Work was canceled before it was started. (Final State) + + public static final EnumSet READY_STATE = EnumSet.of(WorkState.Ready); + public static final EnumSet WORKING_STATE = EnumSet.of(WorkState.Working); + public static final EnumSet FINAL_STATES = EnumSet.of(WorkState.Complete, WorkState.Error, WorkState.Canceled, WorkState.Interrupted); + public static final EnumSet COMPLETE_STATE = EnumSet.of(WorkState.Complete); + public static final EnumSet ERROR_STATE = EnumSet.of(WorkState.Error); + public static final EnumSet CANCELED_STATE = EnumSet.of(WorkState.Canceled); + public static final EnumSet CANCELED_STATES = EnumSet.of(WorkState.Canceled, WorkState.Interrupted, WorkState.Interrupting); + + public boolean isFinalState() + { + return FINAL_STATES.contains(this); + } + + public boolean isInitialState() + { + return this == Ready; + } + +}