/// <summary> /// Initializes a new instance of the ResultSummaryRecord class. /// </summary> /// <param name="verb"> /// The verb whose execution this is the result of. /// </param> /// <param name="disposition"> /// The disposition of the verb execution. /// </param> /// <param name="outputs"> /// The build objects that were produced by this verb execution. /// </param> internal ResultSummaryRecord( IVerb verb, Disposition disposition, IEnumerable<BuildObjectValuePointer> outputs) : this(verb, disposition, outputs, false) { }
private void reexamineVerb(IVerb verb) { //- Perhaps this child knows more since we last tried //- to work upstream from it. foreach (IVerb parentVerb in verb.getVerbs()) { hasher.addVerb(parentVerb); } }
protected IEnumerable <IVerb> getVerifyishVerbs() { // All the available things that make Beat or Basm ... BasmModuleAccumulator acc = new BasmModuleAccumulator(context, upstreamObj, includeAllImps()); // Plus the transitive deps. IEnumerable <IVerb> extraDeps = new IVerb[] { context, boogieAsmBuildExecutableVerb }; return(acc.verbs.Concat(extraDeps).Concat(context.getVerbs())); }
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(); }
public VerbExpression( IVerb verb, INoun subject = null, INoun objct = null, Tense tense = Tense.Past) { Verb = verb; Tense = tense; Subject = subject; Object = objct; }
internal string dbgGetVerbStatus(IVerb verb) { if (completedVerbs.Contains(verb)) { return("completed"); } if (resolvedVerbs.Contains(verb)) { return("submitted"); } return("pending"); }
public void submitVerb(IVerb verb) { verbStateLock.AcquireWriterLock(Timeout.Infinite); //- If lock contention were an issue, we could accumulate these //- on a thread-local collection, then batch them into runnableVerbs //- during the lock inside scheduleAndWait. if (!startedVerbs.Contains(verb)) { runnableVerbs.Add(verb); } verbStateLock.ReleaseLock(); }
private static ILogger Init(IVerb verb, IOptions options) { var logger = InitLogger(options, verb.GetVerbName()); Settings.InitUserConfig(logger); ProcessGlobalArguments(logger, options, Settings.UserConfig); PreRunChecks.PerformChecks(Output.Logger, verb, Settings.UserConfig); return(logger); }
public new void SituationExecutingRecipe(ISituationEffectCommand command) { var tabletopManager = Registry.Retrieve <ITabletopManager>(); situationWindow.SetSlotConsumptions(); StoreStacks(situationWindow.GetOngoingStacks()); if (command.AsNewSituation) { List <IElementStack> stacksToAddToNewSituation = new List <IElementStack>(); if (command.Expulsion != null) { AspectMatchFilter filter = new AspectMatchFilter(command.Expulsion.Filter); var filteredStacks = filter.FilterElementStacks(situationWindow.GetStoredStacks()).ToList(); if (filteredStacks.Any() && command.Expulsion.Limit > 0) { while (filteredStacks.Count > command.Expulsion.Limit) { filteredStacks.RemoveAt(filteredStacks.Count - 1); } stacksToAddToNewSituation = filteredStacks; } } IVerb verbForNewSituation = compendium.GetOrCreateVerbForCommand(command); var scc = new SituationCreationCommand( verbForNewSituation, command.Recipe, SituationState.FreshlyStarted, situationToken as DraggableToken); if (command is SituationEffectCommand seCommand) { scc.SendAway = seCommand.SendAway; } tabletopManager.BeginNewSituation(scc, stacksToAddToNewSituation); situationWindow.DisplayStoredElements(); return; } currentCharacter.AddExecutionsToHistory(command.Recipe.Id, 1); var executor = new SituationEffectExecutor(); executor.RunEffects(command, situationWindow.GetStorageStacksManager(), currentCharacter); if (command.Recipe.EndingFlag != null) { var ending = compendium.GetEndingById(command.Recipe.EndingFlag); tabletopManager.EndGame(ending, this); } situationWindow.DisplayStoredElements(); }
/// <summary> /// Concatenate a collection to this collection. /// </summary> /// <param name="coll">Collection to concatenate</param> public void Concat(VerbCollection coll) { IEnumerator enumColl = coll.GetEnumerator(); while (enumColl.MoveNext()) { IVerb curObj = enumColl.Current as IVerb; if (curObj != null) { this.Add(curObj); } } }
private static void CheckDocker(ILogger logger, IVerb verb, UserConfig config) { PerformanceTesting.Checkpoint("Begin Docker Check"); logger.Trace("checking docker"); if (verb.RequiresDocker && config.Checks.Docker && !Docker.IsRunning()) { logger.Fatal("docker check failed"); throw new FatalException("Docker daemon is unreachable or not running."); } PerformanceTesting.Checkpoint("End Docker Check"); }
public static void BuildPipeline(IContextGeneratingVerb context, BuildObject input, out BuildObject bplFile, out IVerb workerVerb) { BoogieAsmVerifyVerb basmVerb = new BoogieAsmVerifyVerb(context, input, true); SymDiffExtractVerb left = new SymDiffExtractVerb(basmVerb, SymDiffExtractVerb.Mode.LEFT); SymDiffExtractVerb right = new SymDiffExtractVerb(basmVerb, SymDiffExtractVerb.Mode.RIGHT); SymDiffInferVerb infer = new SymDiffInferVerb(left, right); SymDiffMergeConfigVerb mergeConfig = new SymDiffMergeConfigVerb(basmVerb, infer); SymDiffCombineVerb combiner = new SymDiffCombineVerb(left, right, mergeConfig); SymDiffMergeVerb merger = new SymDiffMergeVerb(basmVerb, combiner); bplFile = merger.getOutputFile(); workerVerb = merger; }
public override bool Equals(object obj) { IVerb other = obj as IVerb; if (other != null) { return(this.getAbstractIdentifier().Equals(other.getAbstractIdentifier())); } else { return(false); } }
public ResultSummaryRecord( IVerb verb, Disposition disposition, IEnumerable <BuildObjectValuePointer> outputs) { bool isVerificationTimeout = false; if (verb != null && verb is IRejectable) { isVerificationTimeout = ((IRejectable)verb).resultWasVerificationTimeout(); } Init(verb, disposition, outputs, isVerificationTimeout); }
public static void ExecuteVerb(IVerb verb, IOptions options) { var logger = Init(verb, options); logger.Debug("executing verb"); PerformanceTesting.Checkpoint("Begin Verb"); verb.Execute(options, Output.Logger); logger.Info("execution completed", new { time = PerformanceTesting.GetElapsedMilliseconds() }); Output.Dispose(); }
public override IEnumerable <IVerb> getVerbs() { IEnumerable <IVerb> verbs = new IVerb[] { producer }; verbs = verbs.Union(producer.getVerbs()); return(verbs); //- VerificationResultSummaryVerb depends on objects mentioned by producer, //-but the necessary verbs haven't been mentioned. Is it sufficient for //-the upstream guy (BoogieAsmVerificationObligationList) to ... hopefully ... //-mention them? (Hopefully because he might only be incompletely queried, //-since he's not actually dependent on the verbs he's advertising.) //-Maybe we should provide a way for his complete() method to push the //-verbs into the cache. }
void IHasher.addVerb(IVerb verb) { foreach (BuildObject obj in verb.getOutputs()) { if (outputToVerbMap.ContainsKey(obj)) { Util.Assert(outputToVerbMap[obj].Equals(verb)); } else { outputToVerbMap[obj] = verb; } } }
public void Process(IConnection connection, SmtpCommand command) { SmtpCommand subrequest = new SmtpCommand(command.ArgumentsText); IVerb verbProcessor = SubVerbMap.GetVerbProcessor(subrequest.Verb); if (verbProcessor != null) { verbProcessor.Process(connection, subrequest); } else { connection.WriteResponse( new SmtpResponse(StandardSmtpResponseCode.CommandParameterNotImplemented, "Subcommand {0} not implemented", subrequest.Verb)); } }
private void Init( IVerb verb, Disposition disposition, IEnumerable <BuildObjectValuePointer> outputs, bool isVerificationTimeout) { this._verb = verb; this._disposition = disposition; this._outputs = new List <BuildObjectValuePointer>(outputs); this._isVerificationTimeout = isVerificationTimeout; if (_verb is IRejectable) { _isVerificationTimeout = ((IRejectable)_verb).resultWasVerificationTimeout(); } }
public AttributeParseResult Parse(IEnumerable <string> args) { if (!_attributeHandler.TryParseSelectedVerb(Configuration.Verbs, ref args, out var error, out var verb, out var requestedHelp)) { if (requestedHelp) { if (verb == null) { return(ShowHelp()); } else { return(ShowHelp(verb)); } } else if (error == null) { throw new LogicException("The attribute handled didn't parse the result and no help was requested, but no error was generated."); } else { return(AttributeParseResult.CreateErrorResult(verb, Configuration.Services.GetService <ErrorHandler>(), new[] { error })); } } IVerb safeVerb = verb ?? throw new LogicException("The attribute handler parsed the verb, but didn't return it."); if (!_attributeHandler.TryProcessArguments(safeVerb, Configuration.GetOptions(safeVerb), args, out var optionValues, out var errors)) { return(AttributeParseResult.CreateErrorResult(verb, Configuration.Services.GetService <ErrorHandler>(), errors)); } var verbData = Configuration.GetVerbData(safeVerb); foreach (var optionProperty in verbData.OptionProperties) { var providedOption = optionValues.FirstOrDefault((o) => o.Option == optionProperty.Option); if (providedOption == null) { continue; } optionProperty.SetValue(verbData.Instance, providedOption.Value); } return(AttributeParseResult.CreateSuccessResult(safeVerb, Configuration.Services.GetService <ErrorHandler>(), verbData.Instance)); }
internal Reaction ObserveVerb(ushort verbID, VerbTargetInfo target, TraitsVector reactorTraits, float verbIntensity) { IVerb verbTraits = null; if (ObservedActions.TryGetValue(verbID, out ObservedVerb verb)) { verbTraits = verb.GetTraits(); ObservedActions[verbID] = verb; } else { verb = new ObservedVerb(verbID); verbTraits = verb.GetTraits(); ObservedActions.Add(verbID, verb); } if (!verb.HitLimit) { ++TotalPerceptions; // could also be used to represent desensitization to violence float magnitude = (1.0f / verb.NumberOfTimes) * (1 - verbIntensity); //TraitsVector thisTraits = this; AddVector(verbTraits.ApplyMagnitude(magnitude)); if (verbTraits.VerbType == VerbType.None) { AddVector(verbTraits.ApplyMagnitude(magnitude)); } else if (verb) { } return(new Reaction( (reactorTraits - verbTraits).SumToBounded().Suppress(1 - magnitude), ((TraitsVector)this - verbTraits).SumToBounded().Suppress(1 - magnitude), verbTraits, magnitude, verbIntensity )); } else { return(null); } }
//- Contract: call only when output objects are known to be cached //- (because fetchResult returned non-Stale). public void fetchOutputObjects(IVerb verb, IEnumerable <BuildObjectValuePointer> values, Disposition disp) { if (this.alreadyFetchedVerbs.Contains(verb)) { return; } IEnumerable <BuildObject> objects = verb.getOutputs(); IEnumerable <BuildObject> failureObjs = verb.getFailureOutputs(); objects = objects.Concat(failureObjs); Dictionary <string, BuildObject> objectDict = new Dictionary <string, BuildObject>(); foreach (BuildObject obj in objects) { objectDict.Add(obj.getRelativePath(), obj); } HashSet <BuildObject> recorded = new HashSet <BuildObject>(); foreach (BuildObjectValuePointer value in values) { if (objectDict.ContainsKey(value.relativePath)) { BuildObject obj = objectDict[value.relativePath]; obj.prepareObjDirectory(); this.fetchObject(value, obj); nuObjectContents.bless(obj, value.objectHash, disp); recorded.Add(obj); } else { throw new Exception("Distressing: some BOVPs aren't in obj.getOutputs"); } } IEnumerable <BuildObject> unrecorded = objects.Except(recorded).Except(failureObjs); Util.Assert(unrecorded.Count() == 0 || disp is Failed); foreach (BuildObject obj in unrecorded) { nuObjectContents.bless(obj, null, disp); } this.alreadyFetchedVerbs.Add(verb); }
public void dbgDisplayIndex(Scheduler dbgScheduler) { List <WaitRecord> waitRecords = new List <WaitRecord>(this.waitingVerbs.Values); for (int i = 0; i < waitRecords.Count(); i++) { WaitRecord wr = waitRecords[i]; List <int> depNums = new List <int>(); List <BuildObject> unknownDeps = new List <BuildObject>(); List <string> unscheduledDeps = new List <string>(); foreach (BuildObject dep in wr.knownDeps) { IVerb depOnVerb = dbgScheduler.getParent(dep); if (depOnVerb == null) { unknownDeps.Add(dep); } else if (!this.waitingVerbs.ContainsKey(depOnVerb)) { unscheduledDeps.Add( string.Format( "{0} waiting on {1} {2}", dep, depOnVerb, dbgScheduler.dbgGetVerbStatus(depOnVerb))); } else { WaitRecord depWr = this.waitingVerbs[depOnVerb]; depNums.Add(waitRecords.IndexOf(depWr)); } } Logger.WriteLine( string.Format( "{0}. {1} waits on ({2}), {3} unknown, {4} unscheduled", i, wr.verb, string.Join(",", depNums), unknownDeps.Count(), unscheduledDeps.Count())); this.dbgPreview("Unknown", unknownDeps.Select(it => it.ToString()), 3); this.dbgPreview("Unscheduled", unscheduledDeps, 20); } }
internal void insert(IVerb verb, IEnumerable <BuildObject> knownDeps) { //- insert one fwd pointer for each obj verb is already known to //- depend upon. The fact that this verb is waiting implies that //- one of these deps is stale here and needs built/fetched. WaitRecord waitRecord = new WaitRecord(verb, knownDeps); foreach (BuildObject dep in knownDeps) { if (!fwdDeps.ContainsKey(dep)) { fwdDeps.Add(dep, new HashSet <WaitRecord>()); } fwdDeps[dep].Add(waitRecord); } waitingVerbs.Add(verb, waitRecord); Say("sleeps " + verb); }
/// <summary> /// Initializes a new instance of the ResultSummaryRecord class. /// </summary> /// <param name="verb"> /// The verb whose execution this is the result of. /// </param> /// <param name="disposition"> /// The disposition of the verb execution. /// </param> /// <param name="outputs"> /// The build objects that were produced by this verb execution. /// </param> /// <param name="isRejectableFailure"> /// Whether this result is a rejectable failure. /// </param> internal ResultSummaryRecord( IVerb verb, Disposition disposition, IEnumerable <BuildObjectValuePointer> outputs, bool isRejectableFailure) { this.verb = verb; this.disposition = disposition; this.outputs = new List <BuildObjectValuePointer>(outputs); this.isRejectableFailure = isRejectableFailure; IRejectable rejectableVerb = verb as IRejectable; if (rejectableVerb != null) { this.isRejectableFailure = rejectableVerb.resultWasRejectableFailure(); } }
/// <summary> /// Dispatches a command to the registered sub command matching the next verb in the command /// or writes an error to the client is no match was found. /// </summary> /// <param name="connection">The connection<see cref="Rnwood.SmtpServer.IConnection" />.</param> /// <param name="command">The command<see cref="Rnwood.SmtpServer.SmtpCommand" />.</param> /// <returns> /// A <see cref="System.Threading.Tasks.Task" /> representing the async operation. /// </returns> public virtual async Task Process(IConnection connection, SmtpCommand command) { SmtpCommand subrequest = new SmtpCommand(command.ArgumentsText); IVerb verbProcessor = this.SubVerbMap.GetVerbProcessor(subrequest.Verb); if (verbProcessor != null) { await verbProcessor.Process(connection, subrequest).ConfigureAwait(false); } else { await connection.WriteResponse( new SmtpResponse( StandardSmtpResponseCode.CommandParameterNotImplemented, "Subcommand {0} not implemented", subrequest.Verb)).ConfigureAwait(false); } }
public void Present(IVerb verb) { WriteLine("usage: [verb] [parameters]"); WriteLine($"{verb.Name} parameters:"); foreach (var option in Configuration.GetOptions(verb)) { var line = _parameterFormatter.Format(option.Name); if (!string.IsNullOrWhiteSpace(option.Alias)) { line += " (" + _parameterFormatter.Format(option.Alias) + ")"; } line += "\t" + option.Description; WriteLine("\t" + line); } }
//- Find some parents that could possibly complete in the future and help //- resolve one of these deps. private List <IVerb> robustDiscoverReadyDeps(IEnumerable <BuildObject> staleDeps) { List <IVerb> newParents = new List <IVerb>(); foreach (BuildObject dep in staleDeps) { IVerb parent = hasher.getParent(dep); if (parent != null) { if (completedVerbs.Contains(parent)) { //- Wait, if the parent is completed, why is the child a stale dependency? Util.Assert(false); } newParents.Add(parent); } } return(newParents); }
/// <summary> /// Mark a verb as having failed. /// </summary> /// <param name="verb">The verb that failed.</param> private void markFailed(IVerb verb) { // At least one of verb's inputs has a permanent failure, so we didn't // even try to execute it. Disposition disposition = new Failed("upstream failure"); ResultSummaryRecord summary = new ResultSummaryRecord(verb, disposition, new BuildObjectValuePointer[] { }); // NB never store upstream failures to the persistent cache, because // they depend on our knowledge this run that the upstream verb failed. // If, in another run, the verb or its inputs are modified, produce the // same outputs, but returns success, we'll be stuck pulling this // upstream failure out of cache but calling this verb a failure. ////string inputHash = computeInputHash(verb, false); ////if (inputHash != null) ////{ //// Util.Assert(false); //// // "Upstream failures" will never have a computable inputHash, because their inputs //// // can't be considered known. Even if the upstream verb wrote something to disk, //// // what if the upstream verb changes to no longer fail but still emit the same thing? //// // We wouldn't want to conclude that, because the inputs hadn't changed, this //// // verb still had an upstream failure. //// repository.StoreResult(inputHash, summary); ////} ////else ////{ this.unrecordableFailures[verb] = disposition; ////} // Mark all the verb's outputs as Failed in the repository. foreach (BuildObject obj in verb.getOutputs()) { if (obj is VirtualBuildObject) { this.repository.StoreVirtual(obj, disposition, null); } else { this.repository.AddObject(obj, disposition, null); } } this.verbIsComplete(verb, disposition); }
public AttributeParseResult Parse(IEnumerable <string> args) { if (!_attributeHandler.TryParseSelectedVerb(Configuration.Verbs, ref args, out var error, out var verb, out var requestedHelp)) { if (requestedHelp) { if (verb == null) { return(ShowHelp()); } else { return(ShowHelp(verb)); } } else if (error == null) { throw new LogicException("The attribute handled didn't parse the result and no help was requested, but no error was generated."); } else { return(AttributeParseResult.CreateErrorResult(verb, Configuration.Services.GetService <ErrorHandler>(), new[] { error })); } } IVerb safeVerb = verb ?? throw new InvalidOperationException("The attribute handler parsed the verb, but didn't return it."); if (!_attributeHandler.TryProcessArguments(safeVerb, Configuration.GetOptions(safeVerb), args, out var optionValues, out var errors)) { return(AttributeParseResult.CreateErrorResult(verb, Configuration.Services.GetService <ErrorHandler>(), errors)); } var verbData = Configuration.GetVerbData(safeVerb); foreach (var optionValue in optionValues) { Configuration.GetParameterValueOption(optionValue.Option).SetValue(optionValue.Value); } return(AttributeParseResult.CreateSuccessResult(safeVerb, Configuration.Services.GetService <ErrorHandler>(), verbData.Method, verbData.Instance, verbData.Parameters.Select((x) => x.Value).ToArray())); }
public IEnumerable <BuildObject> getDependencies(IVerb verb, out DependencyDisposition ddisp) { dbgQueries += 1; DependencyResult result; bool present = theCache.TryGetValue(verb, out result); if (!present) { dbgMisses += 1; result = new DependencyResult(); result.deps = verb.getDependencies(out result.ddisp); if (result.ddisp != DependencyDisposition.Incomplete) { //- Can't cache incomplete results, since they may change upon //- later inspection. theCache[verb] = result; } } ddisp = result.ddisp; return(result.deps); }
public IEnumerable<BuildObject> getDependencies(IVerb verb, out DependencyDisposition ddisp) { this.dbgQueries += 1; DependencyResult result; bool present = this.theCache.TryGetValue(verb, out result); if (!present) { this.dbgMisses += 1; result = new DependencyResult(); result.deps = verb.getDependencies(out result.ddisp); if (result.ddisp != DependencyDisposition.Incomplete) { // Can't cache incomplete results, since they may change upon // later inspection. this.theCache[verb] = result; } } ddisp = result.ddisp; return result.deps; }
public bool Execute(IVerb verb, Node destination, int timeout) { try { NetworkRequest request = verb.CreateRequest(); var output = new NetworkRequest(); destination.LastUpdate = Environment.TickCount; if (!string.IsNullOrEmpty(destination.Secret) && string.IsNullOrEmpty(request.AuthKey)) request.AuthKey = destination.Secret; if (!DoRequest(destination.Location, request, out output, timeout)) return false; if (!verb.ReceiveResponse(output)) return false; return true; } catch { return false; } }
/// <summary> /// Prepares the working directory tree for a verb's execution. /// </summary> /// <param name="verb">The verb whose execution we're preparing for.</param> private void PrepareForVerb(WorkingDirectory workingDirectory, IVerb verb) { // Debugging aide: write out the abstract id for this verb. File.WriteAllText(workingDirectory.PathTo("Debug.txt"), verb.getAbstractIdentifier().ToString()); Repository repository = BuildEngine.theEngine.Repository; // Copy all verb inputs from the item cache to here. DependencyDisposition ddisp; foreach (BuildObject input in verb.getDependencies(out ddisp)) { if (!(input is VirtualBuildObject)) { workingDirectory.CreateDirectoryFor(input); // REVIEW: No longer needed? repository.Fetch(workingDirectory, input); } } // Ensures that the directory tree for each of the verb's outputs exists. foreach (BuildObject output in verb.getOutputs()) { workingDirectory.CreateDirectoryFor(output); } }
/// <summary> /// Submits a verb for execution. /// </summary> /// <param name="verb">The verb to submit.</param> public void submitVerb(IVerb verb) { this.verbStateLock.AcquireWriterLock(Timeout.Infinite); // If lock contention were an issue, we could accumulate these // on a thread-local collection, then batch them into runnableVerbs // during the lock inside scheduleAndWait. if (!this.startedVerbs.Contains(verb)) { this.runnableVerbs.Add(verb); } this.verbStateLock.ReleaseLock(); }
/// <summary> /// Checks the cache for a previous execution of this verb operating on /// the same inputs; updates our state with the cached results if so. /// </summary> /// <param name="verb">The verb to check for prior execution.</param> /// <param name="inputHash"> /// An identifier for this verb operating on a specific set of inputs. /// </param> /// <returns> /// True if usable previous execution was found, false otherwise. /// </returns> private bool fetchFromCache(IVerb verb, string inputHash) { try { ResultSummaryRecord summary = this.repository.FetchResult(inputHash); if (summary.Disposition is Stale) { return false; } // REVIEW: Since we aren't asking FetchResult to return failures, // this check is no longer needed. Or at least it won't be once // the "Results" cache is cleared of all existing failure records. if (this.rejectCachedFailures && (summary.Disposition is Failed || summary.IsVerificationTimeout)) { Logger.WriteLine(string.Format( "NOTE: rejecting failure from cache {0}", verb)); return false; } this.Say(string.Format("disposeCurrentVerbs pulls {0} from cache", verb)); // Hey, this verb is already computed! Nothing to do. // Add the verb execution's results to the repository. this.repository.AddVerbResults(verb, summary); this.verbIsComplete(verb, summary.Disposition); return true; } catch (ObjectMissingFromCacheException ex) { Logger.WriteLine(string.Format( "WARNING: expected object {0} missing from cache; discarding cached result {1}", ex, verb)); return false; } }
/// <summary> /// Logs output regarding a verb's execution disposition. /// </summary> /// <param name="verb">The verb in question.</param> /// <param name="disposition">Disposition of the verb execution.</param> private void emitRealtimeReport(IVerb verb, Disposition disposition) { Presentation pr = verb.getRealtimePresentation(disposition); ASCIIPresentater ascii = new ASCIIPresentater(); pr.format(ascii); Logger.Write(ascii.ToString()); }
public void consider(IVerb verb, DbgVerbCondition cond) { consider_inner(new Tuple<IVerb, DbgVerbCondition>(verb, cond)); consider_inner(new Tuple<IVerb, DbgVerbCondition>(verb, DbgVerbCondition.DVTotal)); }
/// <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; }
/// <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 } }
/// <summary> /// Adds a verb to the mapping of build objects to the verb which /// creates them. /// </summary> /// <remarks> /// TODO: Make this private. /// </remarks> /// <param name="verb">The verb to add.</param> internal void addVerb(IVerb verb) { if (!this.knownVerbs.Add(verb)) { // We've already added this verb. return; } // Add all verb outputs to the output-to-verb map. foreach (BuildObject obj in verb.getOutputs()) { if (this.outputToVerbMap.ContainsKey(obj)) { Util.Assert(this.outputToVerbMap[obj].Equals(verb)); } else { this.outputToVerbMap[obj] = verb; } } // Recursively add all the verbs this verb is dependent upon, // so that we have a complete index of outputs back to the // verbs that generate them. foreach (IVerb dependentVerb in verb.getVerbs()) { this.addVerb(dependentVerb); } }
/// <summary> /// Determine the status of a verb (for debugging purposes). /// </summary> /// <param name="verb">Verb being examined.</param> /// <returns>A string containing the verb's current status.</returns> internal string dbgGetVerbStatus(IVerb verb) { if (this.completedVerbs.Contains(verb)) { return "completed"; } if (this.resolvedVerbs.Contains(verb)) { return "submitted"; } return "pending"; }
/// <summary> /// Initializes a new instance of the TaskCompletion class. /// </summary> /// <param name="workingDirectory"> /// The private working directory the task executed in. /// </param> /// <param name="verb"> /// The verb whose completion this instance describes. /// </param> /// <param name="disposition"> /// The disposition of this task. /// </param> public TaskCompletion(WorkingDirectory workingDirectory, IVerb verb, Disposition disposition) { this.workingDirectory = workingDirectory; this.verb = verb; this.disposition = disposition; }
public void SetVerbProcessor(string verb, IVerb verbProcessor) { _processorVerbs[verb] = verbProcessor; }
public MeaningfulCommand(IVerb verb, GameObject verbTool, GameObject verbObject) { Verb = verb; VerbObject = verbObject; VerbTool = verbTool; }
internal bool isWaiting(IVerb verb) { return this.waitingVerbs.ContainsKey(verb); }
/// <summary> /// Initializes a new instance of the ResultSummaryRecord class. /// </summary> /// <param name="verb"> /// The verb whose execution this is the result of. /// </param> /// <param name="disposition"> /// The disposition of the verb execution. /// </param> /// <param name="outputs"> /// The build objects that were produced by this verb execution. /// </param> /// <param name="isRejectableFailure"> /// Whether this result is a rejectable failure. /// </param> internal ResultSummaryRecord( IVerb verb, Disposition disposition, IEnumerable<BuildObjectValuePointer> outputs, bool isRejectableFailure) { this.verb = verb; this.disposition = disposition; this.outputs = new List<BuildObjectValuePointer>(outputs); this.isRejectableFailure = isRejectableFailure; IRejectable rejectableVerb = verb as IRejectable; if (rejectableVerb != null) { this.isRejectableFailure = rejectableVerb.resultWasRejectableFailure(); } }
/// <summary> /// Reexamines a verb to see if it now knows more regarding what other /// verbs need to run first in order to create its dependencies. /// </summary> /// <param name="verb">The verb to reexamine.</param> private void reexamineVerb(IVerb verb) { foreach (IVerb parentVerb in verb.getVerbs()) { this.addVerb(parentVerb); } }
internal void insert(IVerb verb, IEnumerable<BuildObject> knownDeps) { // Insert one fwd pointer for each obj verb is already known to // depend upon. The fact that this verb is waiting implies that // one of these deps is stale here and needs built/fetched. WaitRecord waitRecord = new WaitRecord(verb, knownDeps); foreach (BuildObject dep in knownDeps) { if (!this.fwdDeps.ContainsKey(dep)) { this.fwdDeps.Add(dep, new HashSet<WaitRecord>()); } this.fwdDeps[dep].Add(waitRecord); } this.waitingVerbs.Add(verb, waitRecord); this.Say("sleeps " + verb); }
public VerbOutputsContext(IVerb sourceVerb, bool assertSuspiciousDafnyImpls) { this.sourceVerb = sourceVerb; this.descr = "VerbOutputs(" + sourceVerb + ")"; this.assertSuspiciousDafnyImpls = assertSuspiciousDafnyImpls; }
public WaitRecord(IVerb verb, IEnumerable<BuildObject> knownDeps) { this.verb = verb; this.knownDeps = knownDeps; }
protected IEnumerable<IVerb> getVerifyishVerbs() { // All the available things that make Beat or Basm ... BasmModuleAccumulator acc = new BasmModuleAccumulator(context, upstreamObj, includeAllImps()); // Plus the transitive deps. IEnumerable<IVerb> extraDeps = new IVerb[] { context, boogieAsmBuildExecutableVerb }; return acc.verbs.Concat(extraDeps).Concat(context.getVerbs()); }
/// <summary> /// Mark a verb as completed, and adjust our schedule accordingly. /// </summary> /// <param name="verb">The verb that completed.</param> /// <param name="disp">The disposition of the verb's execution.</param> private void verbIsComplete(IVerb verb, Disposition disp) { ////Say(string.Format(" {0} is complete: {1}", verb, dbgDisposition)); ////if (disp is Failed) ////{ //// // Failures can be hard to debug, since they don't leave any //// // output in nuobj/. So report these even if they aren't //// // built this run. //// emitRealtimeReport(verb, disp); ////} // Invariant: all of this verb's objs are non-Stale. foreach (BuildObject obj in verb.getOutputs()) { ////Say(string.Format(" waking {0}", obj)); IEnumerable<IVerb> wokenSet = this.waitIndex.awaken(obj); ////foreach (IVerb wokenVerb in wokenSet) ////{ //// //Say(string.Format(" {0} woken", wokenVerb)); ////} this.nextVerbs.UnionWith(wokenSet); } this.emitRealtimeReport(verb, disp); this.requiredVerbs.Remove(verb); this.completedVerbs.Add(verb); }
/// <summary> /// Computes a concrete identifier for a verb operation and its /// specific inputs. /// </summary> /// <param name="verb">The verb to compute the hash for.</param> /// <param name="assertHashAvailable"> /// Whether to assert if we can't compute the hash. /// </param> /// <returns> /// A concrete identifier for a verb operation and its specific inputs. /// </returns> private string computeInputHash(IVerb verb, bool assertHashAvailable) { StringBuilder sb = new StringBuilder(); sb.Append(verb.getAbstractIdentifier().getConcreteId()); DependencyDisposition ddisp; foreach (BuildObject obj in this.depCache.getDependencies(verb, out ddisp)) { sb.Append(","); string hash = this.repository.GetHash(obj); Util.Assert(!assertHashAvailable || (hash != null)); sb.Append(hash); } if (ddisp == DependencyDisposition.Failed) { // This happens when we're trying to markFailed, // but the upstream has failed and we can't compute // our dependencies. In that case, markFailed // settles for noting the failure in-process, // but not caching the result. (Okay, since this // failure propagation is cheap to rediscover.) Util.Assert(!assertHashAvailable); return null; } Util.Assert(ddisp == DependencyDisposition.Complete); string rc = Util.hashString(sb.ToString()); return rc; }
public override IEnumerable<IVerb> getVerbs() { IEnumerable<IVerb> verbs = new IVerb[] { this.producer }; verbs = verbs.Union(this.producer.getVerbs()); return verbs; // VerificationResultSummaryVerb depends on objects mentioned by producer, // but the necessary verbs haven't been mentioned. Is it sufficient for // the upstream guy (BoogieAsmVerificationObligationList) to ... hopefully ... // mention them? (Hopefully because he might only be incompletely queried, // since he's not actually dependent on the verbs he's advertising.) // Maybe we should provide a way for his complete() method to push the // verbs into the cache. }
public VerbOutputsContextVerb(IVerb parent, bool assertSuspiciousDafnyImpls) : base(parent.getAbstractIdentifier().ToString(), null) { this.parent = parent; this.assertSuspiciousDafnyImpls = assertSuspiciousDafnyImpls; }
/// <summary> /// Adds the output objects from a cached verb execution to the /// repository, and ensures they are present in the item cache. /// </summary> /// <param name="verb">The verb whose outputs to add.</param> /// <param name="resultRecord"> /// The result summary record of the verb execution. /// </param> /// <remarks> /// Call only when output objects are known to be cached /// (i.e. because FetchResult returned non-Stale). /// REVIEW: This function probably shouldn't be in this file. /// It does something similar for cached verb results that /// the scheduler's recordResult method does for new verb /// executions. Move this there and/or refactor? /// </remarks> public void AddVerbResults(IVerb verb, ResultSummaryRecord resultRecord) { if (this.alreadyAddedVerbs.Contains(verb)) { // We only need to add a cached verb execution's outputs once. return; } Disposition disposition = resultRecord.Disposition; // REVIEW: In the below, some of these IEnumerables should be // HashSets, and the HashSet should be a simple List. // Create a collection of the potential outputs. IEnumerable<BuildObject> outputs = verb.getOutputs(); IEnumerable<BuildObject> failureOutputs = verb.getFailureOutputs(); outputs = outputs.Concat(failureOutputs); Dictionary<string, BuildObject> potentialOutputs = new Dictionary<string, BuildObject>(); foreach (BuildObject obj in outputs) { potentialOutputs.Add(obj.getRelativePath(), obj); } // Compare the actual outputs with the potential outputs, // and add the actual ones to the repository. HashSet<BuildObject> recorded = new HashSet<BuildObject>(); foreach (BuildObjectValuePointer actualOutput in resultRecord.Outputs) { if (potentialOutputs.ContainsKey(actualOutput.RelativePath)) { BuildObject obj = potentialOutputs[actualOutput.RelativePath]; // TODO: Verify that the object exists in the item cache! this.AddObject(obj, disposition, actualOutput.ObjectHash); recorded.Add(obj); // Store a copy of this verb output as a file in the real nuobj directory. Util.Assert(actualOutput.RelativePath.StartsWith(BuildEngine.theEngine.getObjRoot(), StringComparison.Ordinal)); this.itemCache.FetchItemToFile(ItemCacheContainer.Objects, actualOutput.ObjectHash, IronRootDirectory.PathTo(actualOutput.RelativePath)); } else { // Complain if we find interloping outputs. throw new Exception("Distressing: some actual verb outputs aren't in the verb's list of potential outputs"); } } // Create a collection of missing outputs. IEnumerable<BuildObject> unrecorded = outputs.Except(recorded).Except(failureOutputs); // For non-Failed verb runs, complain if all expected outputs don't // show up in the actual outputs. Util.Assert(unrecorded.Count() == 0 || disposition is Failed); // For cached verb runs with permanent failures (i.e. disposition // is Failed), we want to mark all of the expected outputs as Failed // even if no corresponding actual output was produced during the // failed verb run. foreach (BuildObject obj in unrecorded) { this.AddObject(obj, disposition, null); } // Remember that we've already added this verb's outputs. this.alreadyAddedVerbs.Add(verb); }