Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/20/10 05:10:22 (15 years ago)
Author:
swagner
Message:

Committing first results of the refactoring of HeuristicLab.Core and related plugins (#95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.SequentialEngine/3.3/SequentialEngine.cs

    r2546 r2656  
    2424using System.Text;
    2525using HeuristicLab.Core;
    26 using System.Threading;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
     
    4342    /// <remarks>Calls <see cref="EngineBase.Abort"/> of base class <see cref="EngineBase"/> and
    4443    /// <see cref="IOperator.Abort"/> of the current <see cref="IOperator"/>.</remarks>
    45     public override void Abort() {
    46       base.Abort();
     44    public override void Stop() {
     45      base.Stop();
    4746      if (currentOperator != null)
    4847        currentOperator.Abort();
     
    5655    /// is pushed on the stack again.<br/>
    5756    /// If the execution was successful <see cref="EngineBase.OnOperationExecuted"/> is called.</remarks>
    58     protected override void ProcessNextOperation() {
    59       IOperation operation = myExecutionStack.Pop();
    60       if (operation is AtomicOperation) {
    61         AtomicOperation atomicOperation = (AtomicOperation)operation;
    62         IOperation next = null;
    63         try {
    64           currentOperator = atomicOperation.Operator;
    65           next = atomicOperation.Operator.Execute(atomicOperation.Scope);
    66         }
    67         catch (Exception ex) {
    68           // push operation on stack again
    69           myExecutionStack.Push(atomicOperation);
    70           Abort();
    71           ThreadPool.QueueUserWorkItem(delegate(object state) { OnExceptionOccurred(ex);});
    72         }
    73         if (next != null)
    74           myExecutionStack.Push(next);
    75         OnOperationExecuted(atomicOperation);
    76         if (atomicOperation.Operator.Breakpoint) Abort();
    77       } else if (operation is CompositeOperation) {
    78         CompositeOperation compositeOperation = (CompositeOperation)operation;
    79         for (int i = compositeOperation.Operations.Count - 1; i >= 0; i--)
    80           myExecutionStack.Push(compositeOperation.Operations[i]);
     57    protected override void ProcessNextOperator() {
     58      currentOperator = null;
     59      ExecutionContext context = ExecutionStack.Pop();
     60      ExecutionContextCollection next = null;
     61      try {
     62        currentOperator = context.Operator;
     63        next = context.Operator.Execute(context);
     64        currentOperator = null;
    8165      }
     66      catch (Exception ex) {
     67        ExecutionStack.Push(context);
     68        Stop();
     69        OnExceptionOccurred(ex);
     70      }
     71      if (next != null) {
     72        for (int i = next.Count - 1; i >= 0; i--)
     73          ExecutionStack.Push(next[i]);
     74      }
     75      if (context.Operator.Breakpoint)
     76        Stop();
    8277    }
    8378  }
Note: See TracChangeset for help on using the changeset viewer.