Getting tasks

This commit is contained in:
Richard Patel
2018-11-16 04:47:08 +01:00
parent 3c39f0d621
commit 3f85cf679b
6 changed files with 77 additions and 65 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"path"
"sync/atomic"
"time"
)
var activeTasks int32
@@ -40,6 +41,15 @@ func Schedule(c context.Context, remotes <-chan *OD) {
// Upload result when ready
go remote.Watch(results)
for atomic.LoadInt32(&activeTasks) > config.Tasks {
select {
case <-c.Done():
return
case <-time.After(time.Second):
continue
}
}
}
}