Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// This is the only constructor in the API.
 /// </summary>
 public StateMachineFactory(STATE defaultInitialState)
 {
     this.transitionsListNode = null;
     this.defaultInitialState = defaultInitialState;
     this.optimized           = false;
     this.stateMachineTable   = null;
 }
Ejemplo n.º 2
0
 internal TransitionsListNode(StateMachineFactory <Operand, State, Eventtype, Event
                                                   > _enclosing, StateMachineFactory.ApplicableTransition <OPERAND, STATE, EVENTTYPE
                                                                                                           , EVENT> transition, StateMachineFactory.TransitionsListNode next)
 {
     this._enclosing = _enclosing;
     this.transition = transition;
     this.next       = next;
 }
Ejemplo n.º 3
0
 private StateMachineFactory(Org.Apache.Hadoop.Yarn.State.StateMachineFactory <OPERAND
                                                                               , STATE, EVENTTYPE, EVENT> that, StateMachineFactory.ApplicableTransition <OPERAND
                                                                                                                                                          , STATE, EVENTTYPE, EVENT> t)
 {
     this.defaultInitialState = that.defaultInitialState;
     this.transitionsListNode = new StateMachineFactory.TransitionsListNode(this, t, that
                                                                            .transitionsListNode);
     this.optimized         = false;
     this.stateMachineTable = null;
 }
Ejemplo n.º 4
0
 private StateMachineFactory(Org.Apache.Hadoop.Yarn.State.StateMachineFactory <OPERAND
                                                                               , STATE, EVENTTYPE, EVENT> that, bool optimized)
 {
     this.defaultInitialState = that.defaultInitialState;
     this.transitionsListNode = that.transitionsListNode;
     this.optimized           = optimized;
     if (optimized)
     {
         MakeStateMachineTable();
     }
     else
     {
         stateMachineTable = null;
     }
 }
Ejemplo n.º 5
0
        private void MakeStateMachineTable()
        {
            Stack <StateMachineFactory.ApplicableTransition <OPERAND, STATE, EVENTTYPE, EVENT> >
            stack = new Stack <StateMachineFactory.ApplicableTransition <OPERAND, STATE, EVENTTYPE
                                                                         , EVENT> >();
            IDictionary <STATE, IDictionary <EVENTTYPE, StateMachineFactory.Transition <OPERAND,
                                                                                        STATE, EVENTTYPE, EVENT> > > prototype = new Dictionary <STATE, IDictionary <EVENTTYPE
                                                                                                                                                                     , StateMachineFactory.Transition <OPERAND, STATE, EVENTTYPE, EVENT> > >();

            prototype[defaultInitialState] = null;
            // I use EnumMap here because it'll be faster and denser.  I would
            //  expect most of the states to have at least one transition.
            stateMachineTable = new EnumMap <STATE, IDictionary <EVENTTYPE, StateMachineFactory.Transition
                                                                 <OPERAND, STATE, EVENTTYPE, EVENT> > >(prototype);
            for (StateMachineFactory.TransitionsListNode cursor = transitionsListNode; cursor
                 != null; cursor = cursor.next)
            {
                stack.Push(cursor.transition);
            }
            while (!stack.IsEmpty())
            {
                stack.Pop().Apply(this);
            }
        }