Skip to content

Commit

Permalink
Add a comment explaining synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-sucha committed Aug 23, 2023
1 parent 8b68f2a commit 0b6d915
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions logconsumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func (g *TestLogConsumer) Accept(l Log) {
return
}

// Accept is called from a different goroutine than WaitFor.
// We need to synchronize access and notify the waiting goroutine so that it always sees the updated msgs.
g.mu.Lock()
defer g.mu.Unlock()
g.msgs = append(g.msgs, s)
Expand Down

0 comments on commit 0b6d915

Please sign in to comment.