Changeset 9493


Ignore:
Timestamp:
05/14/13 14:03:34 (8 years ago)
Author:
sforsten
Message:

#2052: the lock in ClonedAlgorithm_Started has been removed as well as all code related to the bool variable startPending. startPending is never really used. In the methods it is used, there is no chance that the if statement would evaluate to anything else than true.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r9456 r9493  
    266266    }
    267267
    268     private bool startPending;
    269268    public void Start() {
    270269      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
    271270        throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
    272271
    273       if (Algorithm != null && !startPending) {
    274         startPending = true;
     272      if (Algorithm != null) {
    275273        //create cloned algorithms
    276274        if (clonedAlgorithms.Count == 0) {
     
    335333      if (!pausePending) {
    336334        pausePending = true;
    337         if (!startPending) PauseAllClonedAlgorithms();
     335        PauseAllClonedAlgorithms();
    338336      }
    339337    }
     
    352350      if (!stopPending) {
    353351        stopPending = true;
    354         if (!startPending) StopAllClonedAlgorithms();
     352        StopAllClonedAlgorithms();
    355353      }
    356354    }
     
    654652    private readonly object locker = new object();
    655653    private void ClonedAlgorithm_Started(object sender, EventArgs e) {
    656       lock (locker) {
    657         IAlgorithm algorithm = sender as IAlgorithm;
    658         if (algorithm != null && !results.ContainsKey(algorithm.Name))
    659           results.Add(new Result(algorithm.Name, "Contains results for the specific fold.", algorithm.Results));
    660 
    661         if (startPending) {
    662           int startedAlgorithms = clonedAlgorithms.Count(alg => alg.ExecutionState == ExecutionState.Started);
    663           if (startedAlgorithms == NumberOfWorkers.Value ||
    664              clonedAlgorithms.All(alg => alg.ExecutionState != ExecutionState.Prepared))
    665             startPending = false;
    666 
    667           if (pausePending) PauseAllClonedAlgorithms();
    668           if (stopPending) StopAllClonedAlgorithms();
    669         }
    670       }
     654      IAlgorithm algorithm = sender as IAlgorithm;
     655      if (algorithm != null && !results.ContainsKey(algorithm.Name))
     656        results.Add(new Result(algorithm.Name, "Contains results for the specific fold.", algorithm.Results));
     657
    671658    }
    672659
     
    718705    public event EventHandler Started;
    719706    private void OnStarted() {
    720       startPending = false;
    721707      ExecutionState = ExecutionState.Started;
    722708      EventHandler handler = Started;
Note: See TracChangeset for help on using the changeset viewer.