From 5989ce159c5d4d39a9aca5803573df3f9a1dbbd9 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Thu, 4 Aug 2022 18:11:53 +0200 Subject: [PATCH] Limit initial file loading --- SynchRoGazer.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SynchRoGazer.go b/SynchRoGazer.go index 3a43150..ad85a7f 100644 --- a/SynchRoGazer.go +++ b/SynchRoGazer.go @@ -19,6 +19,7 @@ import ( "os" "runtime" "sync/atomic" + "time" ) type HashFileResult struct { @@ -287,6 +288,11 @@ func main() { path := scanner.Text() atomic.AddInt64(&entries, 1) + for atomic.LoadInt64(&taskCount) >= (int64(*taskLimit) + 1) { + runtime.Gosched() + time.Sleep(time.Millisecond * 20) + } + atomic.AddInt64(&taskCount, 1) go func() { defer atomic.AddInt64(&taskCount, -1)