Skip to content

Commit

Permalink
use sync chan
Browse files Browse the repository at this point in the history
Signed-off-by: sivchari <shibuuuu5@gmail.com>
  • Loading branch information
sivchari committed Sep 24, 2024
1 parent 96ae64f commit a832abf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/infrastructure/inmemory/pkg/runtime/cache/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ func (c *cache) startSyncer(ctx context.Context) error {
c.syncQueue.ShutDown()
}()

syncLoopStarted := make(chan struct{})
go func() {
log.Info("Starting sync loop")
syncLoopStarted <- struct{}{}
for {
select {
case <-time.After(c.syncPeriod / 4):
Expand Down Expand Up @@ -79,6 +81,8 @@ func (c *cache) startSyncer(ctx context.Context) error {
wg.Wait()
}()

<-syncLoopStarted

if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, false, func(context.Context) (done bool, err error) {
if atomic.LoadInt64(&workers) < int64(c.syncConcurrency) {
return false, nil
Expand Down

0 comments on commit a832abf

Please sign in to comment.