Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
taylanisikdemir committed Mar 13, 2024
1 parent 6d270b7 commit 15aa30f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion service/matching/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,12 @@ func ensureAsyncReady(ctxTimeout time.Duration, cb func(ctx context.Context)) (w
closed := make(chan struct{})
ctx, cancel := context.WithTimeout(context.Background(), ctxTimeout)
go func() {
defer cancel()
// Defers are stacked. The last one added is the first one to run.
// We want to cancel the context which will make the callback return because it's a Poll,
// and then close the closed channel.
// This way the returned wait function will block until the callback has returned.
defer close(closed)
defer cancel()

close(running)
cb(ctx)
Expand Down

0 comments on commit 15aa30f

Please sign in to comment.