Exemplo n.º 1
0
        /// <summary>
        /// Returns the next choice to schedule.
        /// </summary>
        /// <param name="next">Next</param>
        /// <param name="choices">Choices</param>
        /// <param name="current">Curent</param>
        /// <returns>Boolean</returns>
        public override bool GetNext(out ISchedulable next, List <ISchedulable> choices, ISchedulable current)
        {
            CaptureAndCheckProgramState();

            if (IsReplayingCycle)
            {
                var enabledChoices = choices.Where(choice => choice.IsEnabled).ToList();
                if (enabledChoices.Count == 0)
                {
                    next = null;
                    return(false);
                }

                ScheduleStep nextStep = PotentialCycle[CurrentCycleIndex];
                if (nextStep.Type != ScheduleStepType.SchedulingChoice)
                {
                    Debug.WriteLine("<LivenessDebug> Trace is not reproducible: next step is not a scheduling choice.");
                    EscapeUnfairCycle();
                    return(SchedulingStrategy.GetNext(out next, choices, current));
                }

                Debug.WriteLine("<LivenessDebug> Replaying '{0}' '{1}'.", nextStep.Index, nextStep.ScheduledMachineId);

                next = enabledChoices.FirstOrDefault(choice => choice.Id == nextStep.ScheduledMachineId);
                if (next == null)
                {
                    Debug.WriteLine("<LivenessDebug> Trace is not reproducible: cannot detect machine with id '{0}'.", nextStep.ScheduledMachineId);
                    EscapeUnfairCycle();
                    return(SchedulingStrategy.GetNext(out next, choices, current));
                }

                SchedulingStrategy.ForceNext(next, choices, current);

                CurrentCycleIndex++;
                if (CurrentCycleIndex == PotentialCycle.Count)
                {
                    CurrentCycleIndex = 0;
                }

                return(true);
            }
            else
            {
                return(SchedulingStrategy.GetNext(out next, choices, current));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns the next choice to schedule.
 /// </summary>
 /// <param name="next">Next</param>
 /// <param name="choices">Choices</param>
 /// <param name="current">Curent</param>
 /// <returns>Boolean</returns>
 public override bool GetNext(out ISchedulable next, List <ISchedulable> choices, ISchedulable current)
 {
     CheckLivenessTemperature();
     return(SchedulingStrategy.GetNext(out next, choices, current));
 }