gemini-code-assist[bot] commented on code in PR #38734:
URL: https://github.com/apache/beam/pull/38734#discussion_r3320140349
##########
sdks/go/pkg/beam/runners/prism/internal/engine/elementmanager.go:
##########
@@ -2496,7 +2499,9 @@ func (em *ElementManager) wakeUpAt(t mtime.Time) {
// only create this goroutine if we have real-time clock
enabled (also implying the pipeline does not have TestStream).
go func(fireAt time.Time) {
time.AfterFunc(time.Until(fireAt), func() {
+ em.refreshCond.L.Lock()
em.refreshCond.Broadcast()
+ em.refreshCond.L.Unlock()
Review Comment:

The outer goroutine `go func(fireAt time.Time) { ... }(t.ToTime())` is
redundant because `time.AfterFunc` is non-blocking and already runs the
provided function in its own goroutine when the timer fires. Spawning an extra
goroutine just to call `time.AfterFunc` is unnecessary and can be simplified by
calling `time.AfterFunc` directly.
For example:
```go
time.AfterFunc(time.Until(t.ToTime()), func() {
em.refreshCond.L.Lock()
em.refreshCond.Broadcast()
em.refreshCond.L.Unlock()
})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]