Skip to content

Instantly share code, notes, and snippets.

@tsukanov-as
Created August 31, 2018 13:10
Show Gist options
  • Save tsukanov-as/4a75e731d959017d7238e5ce456e6f28 to your computer and use it in GitHub Desktop.
Save tsukanov-as/4a75e731d959017d7238e5ce456e6f28 to your computer and use it in GitHub Desktop.
Procedure ParseFiles(Path) Export
Files = FindFiles(Path, "*.bsl", True);
Total = Files.Count();
MaxJobs = 8;
JobList = New Array(MaxJobs);
JobArgs = New Array(1);
Index = 0;
Taken = 0;
While Taken < Total Do
If JobList[Index] = Undefined Or JobList[Index].State <> BackgroundJobState.Active Then
JobArgs[0] = Files[Taken].FullName;
JobList[Index] = BackgroundJobs.Execute("Jobs.ParseFile", JobArgs);
Taken = Taken + 1;
EndIf;
Index = Index + 1;
If Index = MaxJobs Then
JobList = BackgroundJobs.WaitForExecutionCompletion(JobList, 60);
Index = 0;
Message = New UserMessage;
Message.Text = Format(Int(Taken * 100 / Total), "NZ=0; NG=");
Message.Message();
EndIf;
EndDo;
EndProcedure // ParseFiles()
Procedure ParseFile(FileName) Export
TextReader = New TextReader(FileName);
Source = TextReader.Read();
BSLParser = Cache.GetDataProcessor("BSLParser");
Module = BSLParser.ParseModule(Source);
TextReader.Close()
EndProcedure // ParseFile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment