This commit is contained in:
Alex Berry 2020-03-04 19:47:34 +00:00
parent b9d529161c
commit 435d04cd6c

View File

@ -1,4 +1,4 @@
# Default params, if $Cores must be set to 0 to automatically detect core count. # Default params, $Cores must be set to 0 to automatically detect core count.
Param( Param(
[Int]$Cores = 0 [Int]$Cores = 0
) )
@ -25,10 +25,10 @@ $Block = {
& cd $workdir; .\pawncc.exe $file & cd $workdir; .\pawncc.exe $file
} }
#Remove all jobs, in case there are old ones from a failed build # Remove all jobs, in case there are old ones from a failed build
Get-Job | Remove-Job Get-Job | Remove-Job
#Start the jobs. Max jobs running simultaneously defined by $MaxThreads set above. # Start the jobs. Max jobs running simultaneously defined by $MaxThreads set above.
foreach($file in $files){ foreach($file in $files){
While ($(Get-Job -state running).count -ge $MaxThreads){ While ($(Get-Job -state running).count -ge $MaxThreads){
Start-Sleep -Milliseconds 3 Start-Sleep -Milliseconds 3
@ -36,15 +36,15 @@ foreach($file in $files){
Start-Job -Scriptblock $Block -ArgumentList $file, $workdir Start-Job -Scriptblock $Block -ArgumentList $file, $workdir
} }
#Once last job has been started, wait for all jobs to finish. # Once last job has been started, wait for all jobs to finish.
While ($(Get-Job -State Running).count -gt 0){ While ($(Get-Job -State Running).count -gt 0){
start-sleep 1 start-sleep 1
} }
#Get information from each job. # Get information from each job.
foreach($job in Get-Job){ foreach($job in Get-Job){
$info= Receive-Job -Id ($job.Id) $info= Receive-Job -Id ($job.Id)
} }
#Remove all jobs created. # Remove all jobs created.
Get-Job | Remove-Job Get-Job | Remove-Job