From ea6b102678c1e17f3c8c850286aaff2375e5280e Mon Sep 17 00:00:00 2001 From: empathicqubit Date: Thu, 29 Apr 2021 05:33:47 -0400 Subject: [PATCH] More useless tweaks to fix Windows --- pool.lua | 4 +++- util.lua | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pool.lua b/pool.lua index edc6ad2..0c8de75 100644 --- a/pool.lua +++ b/pool.lua @@ -5,7 +5,9 @@ local util = dofile(base.."/util.lua") local serpent = dofile(base.."/serpent.lua") local libDeflate = dofile(base.."/LibDeflate.lua") -local hasThreads = not util.isWin and config.NeatConfig.Threads > 1 +local hasThreads = + not util.isWin and + config.NeatConfig.Threads > 1 local Runner = nil if hasThreads then Runner = dofile(base.."/runner-wrapper.lua") diff --git a/util.lua b/util.lua index 15c05c9..2f8935f 100644 --- a/util.lua +++ b/util.lua @@ -99,8 +99,13 @@ function _M.waitForChange(filenames, count, wild) local sec, usec = utime() print(string.format('Starting watching file at %d', sec * 1000000 + usec)) - return _M.popenCmd([[powershell "$filename = ']]..wild.. - [[' ; $targetCount = ]]..count..[[ ; $count = 0 ; Register-ObjectEvent (New-Object IO.FileSystemWatcher (Split-Path $filename), (Split-Path -Leaf $filename) -Property @{ IncludeSubdirectories = $false ; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}) -EventName Changed -SourceIdentifier RunnerDataChanged -Action { $count += 1 ; if ( $count -ge $targetCount ) { [Environment]::Exit(0) } } ; while($true) { Start-Sleep -Milliseconds 1 }"]]) + local poppet = _M.popenCmd([[powershell "$filename = ']]..wild.. + [[' ; $targetCount = ]]..count..[[ ; $count = 0 ; $action = { $count += 1 ; if ( $count -ge $targetCount ) { [Environment]::Exit(0) } } ; (Register-ObjectEvent (New-Object IO.FileSystemWatcher (Split-Path $filename), (Split-Path -Leaf $filename) -Property @{ IncludeSubdirectories = $false ; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}) -EventName Changed -SourceIdentifier RunnerDataChanged -Action $action).Name ; while($true) { Start-Sleep -Seconds 5 }"]]) + + while poppet:read('*l'):sub(1, 17) ~= 'RunnerDataChanged' do + end + + return poppet else local watchCmd = '' if count == 1 then