- Timestamp:
- 04/16/13 13:13:41 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.ParallelEngine/3.3
- Property svn:ignore
-
old new 5 5 HeuristicLab.ParallelEngine-3.3.csproj.user 6 6 Plugin.cs 7 *.user
-
- Property svn:ignore
-
branches/OaaS/HeuristicLab.ParallelEngine/3.3/ParallelEngine.cs
r7259 r9363 37 37 public class ParallelEngine : Engine { 38 38 private CancellationToken cancellationToken; 39 private ParallelOptions parallelOptions; 40 41 [Storable(DefaultValue = -1)] 42 private int degreeOfParallelism; 43 public int DegreeOfParallelism { 44 get { return degreeOfParallelism; } 45 set { 46 if (degreeOfParallelism != value) { 47 degreeOfParallelism = value; 48 OnDegreeOfParallelismChanged(); 49 } 50 } 51 } 39 52 40 53 [StorableConstructor] 41 54 protected ParallelEngine(bool deserializing) : base(deserializing) { } 42 protected ParallelEngine(ParallelEngine original, Cloner cloner) : base(original, cloner) { } 43 public ParallelEngine() : base() { } 55 protected ParallelEngine(ParallelEngine original, Cloner cloner) 56 : base(original, cloner) { 57 this.DegreeOfParallelism = original.DegreeOfParallelism; 58 } 59 public ParallelEngine() 60 : base() { 61 this.degreeOfParallelism = -1; 62 } 44 63 45 64 public override IDeepCloneable Clone(Cloner cloner) { … … 47 66 } 48 67 68 public event EventHandler DegreeOfParallelismChanged; 69 protected void OnDegreeOfParallelismChanged() { 70 var handler = DegreeOfParallelismChanged; 71 if (handler != null) handler(this, EventArgs.Empty); 72 } 73 74 49 75 protected override void Run(CancellationToken cancellationToken) { 50 76 this.cancellationToken = cancellationToken; 77 parallelOptions = new ParallelOptions(); 78 parallelOptions.MaxDegreeOfParallelism = DegreeOfParallelism; 51 79 Run(ExecutionStack); 52 80 } … … 65 93 coll = (OperationCollection)next; 66 94 if (coll.Parallel) { 67 Task[] tasks = new Task[coll.Count];68 95 Stack<IOperation>[] stacks = new Stack<IOperation>[coll.Count]; 69 96 for (int i = 0; i < coll.Count; i++) { 70 97 stacks[i] = new Stack<IOperation>(); 71 98 stacks[i].Push(coll[i]); 72 tasks[i] = Task.Factory.StartNew(Run, stacks[i], cancellationToken);73 99 } 74 100 try { 75 Task.WaitAll(tasks);101 Parallel.ForEach(stacks, parallelOptions, Run); 76 102 } 77 103 catch (AggregateException ex) {
Note: See TracChangeset
for help on using the changeset viewer.