MCPcopy Index your code
hub / github.com/coder/coder / WaitUntilEmpty

Method WaitUntilEmpty

codersdk/agentsdk/logs.go:492–517  ·  view source on GitHub ↗

WaitUntilEmpty waits until the LogSender's queues are empty or the given context expires.

(ctx context.Context)

Source from the content-addressed store, hash-verified

490
491// WaitUntilEmpty waits until the LogSender's queues are empty or the given context expires.
492func (l *LogSender) WaitUntilEmpty(ctx context.Context) error {
493 ctxDone := false
494 nevermind := make(chan struct{})
495 defer close(nevermind)
496 go func() {
497 select {
498 case <-ctx.Done():
499 l.L.Lock()
500 defer l.L.Unlock()
501 ctxDone = true
502 l.Broadcast()
503 return
504 case <-nevermind:
505 return
506 }
507 }()
508 l.L.Lock()
509 defer l.L.Unlock()
510 for len(l.queues) != 0 && !ctxDone {
511 l.Wait()
512 }
513 if len(l.queues) == 0 {
514 return nil
515 }
516 return ctx.Err()
517}
518
519type ScriptLogger struct {
520 sender *LogSender

Callers 4

TestLogSender_MainlineFunction · 0.95
CloseMethod · 0.80

Calls 5

ErrMethod · 0.80
WaitMethod · 0.65
DoneMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45