/// <inhreritdoc /> public override Possible <ISourceFile>[] ParseAndBindSpecs(SpecWithOwningModule[] specs) { // It is very important to dispose the cancellation registration for parse/bind case as well. cancellationTokenChain.Dispose(); // Not using queue here for now. var result = ParallelAlgorithms.ParallelSelect( specs, spec => { // Parsing and binding the given spec. return (TryParseSpec(spec).GetAwaiter().GetResult() .Then(ps => { BindSourceFile(new ParsedSpecWithOwningModule(parsedFile: ps, owningModule: spec.OwningModule)); return ps.BindDiagnostics.Count == 0 ? new Possible <ISourceFile>(ps) : new BindingFailure(spec.OwningModule.Descriptor, ps); })); }, DegreeOfParallelism, CancellationToken); return(result.ToArray()); }
private IReadOnlyCollection <FileModuleLiteral> ConvertWorkspaceInParallel(Workspace workspace, AbsolutePath configPath) { var package = CreateDummyPackageFromPath(configPath); var parserContext = CreateParserContext(resolver: null, package: package, origin: null); // Need to use ConfigurationModule and not a set of source specs. // We convert configuration which is not a source specs. Contract.Assert(workspace.ConfigurationModule != null); var specs = workspace.ConfigurationModule.Specs.ToList(); return(ParallelAlgorithms.ParallelSelect( specs, kvp => ConvertAndRegisterSourceFile(parserContext, workspace, sourceFile: kvp.Value, path: kvp.Key, isConfig: kvp.Key == configPath), DegreeOfParallelism)); }