Changeset 15376 for trunk/sources/HeuristicLab.ParallelEngine
- Timestamp:
- 09/20/17 15:56:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ParallelEngine/3.3/ParallelEngine.cs
r15368 r15376 101 101 try { 102 102 Parallel.ForEach(stacks, parallelOptions, Run); 103 } 104 catch (Exception ex) { 105 OperationCollection remaining = new OperationCollection() { Parallel = true }; 106 for (int i = 0; i < stacks.Length; i++) { 107 if (stacks[i].Count == 1) 108 remaining.Add(stacks[i].Pop()); 109 if (stacks[i].Count > 1) { 110 OperationCollection ops = new OperationCollection(); 111 while (stacks[i].Count > 0) 112 ops.Add(stacks[i].Pop()); 113 remaining.Add(ops); 114 } 115 } 116 if (remaining.Count > 0) executionStack.Push(remaining); 103 } catch (OperationCanceledException) { 104 RepairStack(executionStack, stacks); 105 throw; 106 } catch (AggregateException) { 107 RepairStack(executionStack, stacks); 117 108 throw; 118 109 } … … 128 119 catch (Exception ex) { 129 120 executionStack.Push(operation); 130 if (ex is OperationCanceledException) throw ex;121 if (ex is OperationCanceledException) throw; 131 122 else throw new OperatorExecutionException(operation.Operator, ex); 132 123 } … … 135 126 } 136 127 } 128 129 private static void RepairStack(Stack<IOperation> executionStack, Stack<IOperation>[] parallelExecutionStacks) { 130 OperationCollection remaining = new OperationCollection() { Parallel = true }; 131 for (int i = 0; i < parallelExecutionStacks.Length; i++) { 132 if (parallelExecutionStacks[i].Count == 1) 133 remaining.Add(parallelExecutionStacks[i].Pop()); 134 if (parallelExecutionStacks[i].Count > 1) { 135 OperationCollection ops = new OperationCollection(); 136 while (parallelExecutionStacks[i].Count > 0) 137 ops.Add(parallelExecutionStacks[i].Pop()); 138 remaining.Add(ops); 139 } 140 } 141 if (remaining.Count > 0) executionStack.Push(remaining); 142 } 137 143 } 138 144 }
Note: See TracChangeset
for help on using the changeset viewer.