Limit initial file loading
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
DataHoarder 2022-08-04 18:11:53 +02:00
parent 80f91c85f1
commit 5989ce159c
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk

View file

@ -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)