private void PerformMission(MissionWrapper mission, IArgumentHolder globalArgumentHolder, Barrier finishingBarrier) { mission.RunState = RunState.RUNNING; var result = mission.ActualMission.Perform(mission.ArgumentHolder); globalArgumentHolder.RegisterResult(mission.ActualMission.Name, result); foreach (var dependantMission in mission.DependantMissions) { bool shouldPerform = false; lock (dependantMission) { dependantMission.ArgumentHolder.RegisterResult(mission.ActualMission.Name, result); dependantMission.UnmetDependencies--; if (dependantMission.UnmetDependencies == 0) { shouldPerform = true; } } if (shouldPerform) { var taskToPerform = dependantMission; Task.Run(() => PerformMission(taskToPerform, globalArgumentHolder, finishingBarrier)); } } mission.RunState = RunState.FINISHED; finishingBarrier.RemoveParticipant(); }
public virtual object Perform(IArgumentHolder holder) { _isPerformedSemaphore.Release(); Interlocked.Increment(ref _runCounter); Arguments = holder; if (_canFinishSemaphore != null) { _canFinishSemaphore.WaitOne(); } return(null); }
public override object Perform(IArgumentHolder holder) { base.Perform(holder); return(Value); }
public object Perform(IArgumentHolder argumentHolder) { return(_missionAction(argumentHolder)); }