示例#1
0
            /// <summary>
            ///   Adds the states stored in the <see cref="_transitions" /> cache.
            /// </summary>
            private void AddStates()
            {
                if (_transitions.Count == 0)
                {
                    throw new InvalidOperationException("Deadlock detected.");
                }

                var transitionCount = 0;

                _stateStack.PushFrame();

                for (var i = 0; i < _transitions.Count; ++i)
                {
                    var transition = _transitions[i];
                    if (!transition->IsValid)
                    {
                        continue;
                    }

                    // Store the state if it hasn't been discovered before
                    int index;
                    if (_states.AddState(transition->TargetState, out index))
                    {
                        Interlocked.Increment(ref _context._stateCount);
                        _stateStack.PushState(index);
                    }

                    // Check if the invariant is violated; if so, generate a counter example and abort
                    if (!transition->Formulas[0])
                    {
                        _context._loadBalancer.Terminate();
                        CreateCounterExample(endsWithException: false);

                        return;
                    }

                    ++transitionCount;
                }

                Interlocked.Add(ref _context._transitionCount, transitionCount);
                Interlocked.Add(ref _context._computedTransitionCount, _transitions.ComputedTransitionCount);
            }