Free cookie consent management tool by TermsFeed Policy Generator

Changeset 36


Ignore:
Timestamp:
03/01/08 20:34:08 (17 years ago)
Author:
gkronber
Message:

shaky version of stop functionality (ticket #2). Open problem: continue distributed execution after engine stop. Right now after stopping the engine the waiting operations are executed locally.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DistributedEngine/DistributedEngine.cs

    r35 r36  
    3838    private string serverAddress;
    3939    private bool cancelRequested;
     40    private CompositeOperation waitingOperations;
    4041    public string ServerAddress {
    4142      get { return serverAddress; }
     
    4849    public override bool Terminated {
    4950      get {
    50         return myExecutionStack.Count == 0 && runningEngines.Count == 0;
     51        return myExecutionStack.Count == 0 && runningEngines.Count == 0 && waitingOperations==null;
    5152      }
    5253    }
     
    100101          base.Abort();
    101102          cancelRequested = false;
     103          if(waitingOperations != null && waitingOperations.Operations.Count != 0) {
     104            myExecutionStack.Push(waitingOperations);
     105            waitingOperations = null;
     106          }
    102107          return;
    103108        }
     
    117122            }
    118123            OnOperationExecuted(engineOperations[engineGuid]);
    119             if(resultEngine.ExecutionStack.Count != 0) {
    120               foreach(IOperation op in resultEngine.ExecutionStack) {
    121                 myExecutionStack.Push(op);
     124
     125            if(cancelRequested & resultEngine.ExecutionStack.Count != 0) {
     126              if(waitingOperations == null) {
     127                waitingOperations = new CompositeOperation();
     128                waitingOperations.ExecuteInParallel = false;
    122129              }
     130              CompositeOperation task = new CompositeOperation();
     131              while(resultEngine.ExecutionStack.Count > 0) {
     132                AtomicOperation oldOperation = (AtomicOperation)resultEngine.ExecutionStack.Pop();
     133                if(oldOperation.Scope == resultEngine.InitialOperation.Scope) {
     134                  oldOperation = new AtomicOperation(oldOperation.Operator, oldScope);
     135                }
     136                task.AddOperation(oldOperation);
     137              }
     138              waitingOperations.AddOperation(task);
    123139            }
    124140            runningEngines.Remove(engineGuid);
Note: See TracChangeset for help on using the changeset viewer.