public override void AddOperation <TOperation>(ICheckConstraint constraint) { var operation = Activator.CreateInstance <TOperation>() as BasicOperation <T>; var operationPair = new OperationDuplex <T>(new OperationInvoker <T>(operation), constraint); ParallelOperations.Add(operationPair); }
/// <summary> /// Gets a generator over Tasks and adjusts the task path as constraints /// fail or pass if there are branch conditions included. /// </summary> /// <returns></returns> public IEnumerable GenerateTaskList() { IEnumerable tasks = Tasks; var enumerator = tasks.GetEnumerator(); for (; enumerator.MoveNext();) { var task = (OperationDuplex <T>)enumerator.Current; // TODO: this smells like object incest. Interface maybe?? if (task.Constraint is BranchCondition) { var constraint = (BranchCondition)task.Constraint; var cond = new BranchCondition(constraint, () => { var enumerable = constraint.BranchPoint.GetRemainingOperations(); if (enumerable != null) { enumerator = enumerable.GetEnumerator(); } }); task = new OperationDuplex <T>(task.Command, cond); } yield return(task); } }
public override void AddOperation(Func <T, T> function, ICheckConstraint constraint, IDeclaredOperation name) { InitializeDeclaredOperation(name); var operationPair = new OperationDuplex <T>(new FunctionInvoker <T>(function), constraint); taskList.Tasks.Add(operationPair); }
public override void AddOperation <TOperation>() { var operation = Activator.CreateInstance <TOperation>(); var operationPair = new OperationDuplex <T>(new OperationInvoker <T>(operation as BasicOperation <T>)); ParallelOperations.Add(operationPair); }
public ThreadProxy(ref Dispatcher <T> engine, OperationDuplex <T> threadStartFunction, T parameter, ref ManualResetEvent finishedEvent) { _finishedEvent = finishedEvent; _function = threadStartFunction; _data = parameter; _engine = engine; }
public override void AddOperation <TOperation>(ICheckConstraint constraint) { var operation = Activator.CreateInstance <TOperation>(); var operationPair = new OperationDuplex <T>(new OperationInvoker <T>(operation as BasicOperation <T>), constraint); taskList.Tasks.Add(operationPair); }
public override void AddOperation <TType>() { var operation = Activator.CreateInstance <TType>(); var operationPair = new OperationDuplex <T>(new OperationInvoker <T>(operation as BasicOperation <T>)); taskList.Tasks.Add(operationPair); }
private ManualResetEvent QueueOperation(OperationDuplex <T> function, T data, ManualResetEvent finishedEvent) { var threadContainer = new ThreadProxy(ref _engine, function, data, ref finishedEvent); ThreadPool.QueueUserWorkItem(a => threadContainer.Start()); return(finishedEvent); }
public ParallelSplitBuilder(TaskList <T> taskList) : base(taskList) { ParallelOperations = new ParallelInvoker <T>(); if (null != taskList.Tasks && 0 != taskList.Tasks.Count) { OperationDuplex <T> leftOver = taskList.Tasks[taskList.Tasks.Count - 1]; taskList.Tasks.RemoveAt(taskList.Tasks.Count - 1); ParallelOperations.Add(leftOver); } }
public virtual T Execute(OperationDuplex <T> operationPair, T current) { if (ConstraintResult(operationPair.Constraint)) { try { current = operationPair.Command.Execute(current); LastOperationSucceeded = true; } catch (Exception ex) { while (ex is System.Reflection.TargetInvocationException) { ex = ex.InnerException; } switch (ErrorHandler.Handle(ex, current)) { case ErrorLevel.Ignored: LastOperationSucceeded = true; break; case ErrorLevel.Handled: LastOperationSucceeded = false; break; case ErrorLevel.Fatal: LastOperationSucceeded = false; throw ex; default: // This line should theoretically be dead code. throw new ArgumentOutOfRangeException("invalid member of ErrorLevel enum"); } } current = ExecutePolicies(operationPair.Command, current); } Context = current; return(Context); }
public override void AddOperation(IOperation <T> operation, ICheckConstraint constraint) { var operationPair = new OperationDuplex <T>(new OperationInvoker <T>(operation as BasicOperation <T>), constraint); ParallelOperations.Add(operationPair); }
public override void AddOperation(IWorkflow <T> workflow) { var operationPair = new OperationDuplex <T>(new WorkflowInvoker <T>(workflow)); taskList.Tasks.Add(operationPair); }
public override void AddOperation(IOperation <T> operation) { var operationPair = new OperationDuplex <T>(new OperationInvoker <T>(operation as BasicOperation <T>)); ParallelOperations.Add(operationPair); }
public override void AddOperation(IWorkflow <T> workflow, ICheckConstraint constraint) { var operationPair = new OperationDuplex <T>(new WorkflowInvoker <T>(workflow), constraint); ParallelOperations.Add(operationPair); }
public override void AddOperation(IWorkflow <T> workflow) { var operationPair = new OperationDuplex <T>(new WorkflowInvoker <T>(workflow)); ParallelOperations.Add(operationPair); }
public override void AddOperation(Func <T, T> function) { var operationPair = new OperationDuplex <T>(new FunctionInvoker <T>(function)); taskList.Tasks.Add(operationPair); }
public void Add(OperationDuplex <T> operation) { RegisteredOperations.Add(operation); }
public override void AddOperation(Func <T, T> function) { var operationPair = new OperationDuplex <T>(new FunctionInvoker <T>(function)); ParallelOperations.Add(operationPair); }
public override void AddOperation(Func <T, T> function, ICheckConstraint constraint) { var operationPair = new OperationDuplex <T>(new FunctionInvoker <T>(function), constraint); ParallelOperations.Add(operationPair); }
public virtual T Execute(OperationDuplex <T> operationPair) { return(Execute(operationPair, default(T))); }
public override void AddOperation(IOperation <T> operation) { var operationPair = new OperationDuplex <T>(new OperationInvoker <T>(operation as BasicOperation <T>)); taskList.Tasks.Add(operationPair); }