void startTask(IVerb verb) { runningTasks += 1; IVerbWorker worker = verb.getWorker(); if (worker.isSync() == IsSync.Sync) { completeTask(verb, worker); } else { AsyncVerbTask task = new AsyncVerbTask(this, worker, verb); Say(String.Format("scheduling {0}", verb)); #pragma warning disable 162 if (debugOneThread) { task.Run(); } else { new Thread(new ThreadStart(task.Run)).Start(); } #pragma warning restore 162 } }
void completeTask(IVerb verb, IVerbWorker worker) { taskCompletionsLock.AcquireWriterLock(Timeout.Infinite); Disposition disp = worker.complete(); TaskCompletion tc = new TaskCompletion(verb, disp); taskCompletions.Add(tc); completionEvent.Set(); taskCompletionsLock.ReleaseWriterLock(); }
/// <summary> /// Completes a task (verb run). /// </summary> /// <remarks> /// Note that for Async verb workers, this method runs on a separate thread. /// </remarks> /// <param name="verb">The verb which was run.</param> /// <param name="worker">The verb's worker.</param> private void completeTask(IVerb verb, IVerbWorker worker) { this.taskCompletionsLock.AcquireWriterLock(Timeout.Infinite); Disposition disp = worker.Complete(); TaskCompletion tc = new TaskCompletion(worker.GetWorkingDirectory(), verb, disp); this.taskCompletions.Add(tc); this.completionEvent.Set(); this.taskCompletionsLock.ReleaseWriterLock(); }
/// <summary> /// Starts a task (i.e. runs a verb). /// </summary> /// <param name="verb">The verb to run.</param> private void startTask(IVerb verb) { this.runningTasks += 1; // We execute the verb in a private build tree (WorkingDirectory). WorkingDirectory workingDirectory = new WorkingDirectory(BuildEngine.theEngine.getIronRoot()); // Note that we call PrepareForVerb prior to the verb's getWorker // method as the getWorker call might do some of the work directly. // REVIEW: We might want to change our contract with getWorker to // disallow it from touching files in the working directory (so we // don't have to prep the working dir in the remote execution case). this.PrepareForVerb(workingDirectory, verb); IVerbWorker worker = verb.getWorker(workingDirectory); if (worker.IsSync() == VerbWorkerType.Sync) { this.completeTask(verb, worker); } else { AsyncVerbTask task = new AsyncVerbTask(this, worker, verb); Say(string.Format("scheduling {0}", verb)); #pragma warning disable 162 if (DebugOneThread) { task.Run(); } else { new Thread(new ThreadStart(task.Run)).Start(); } #pragma warning restore 162 } }
public AsyncVerbTask(AsyncRunner runner, IVerbWorker worker, IVerb verb) { this.runner = runner; this.worker = worker; this.verb = verb; }
/// <summary> /// Initializes a new instance of the AsyncVerbTask class. /// </summary> /// <param name="runner"> /// The verb running part of the scheduler. /// </param> /// <param name="worker"> /// The worker of this verb task. /// </param> /// <param name="verb"> /// The verb associated with this task/worker. /// </param> public AsyncVerbTask(VerbRunner runner, IVerbWorker worker, IVerb verb) { this.runner = runner; this.worker = worker; this.verb = verb; }