MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / waitForBGTCompletion

Function waitForBGTCompletion

db/database.go:731–745  ·  view source on GitHub ↗

waitForBGTCompletion waits for all the background tasks to finish.

(ctx context.Context, waitTimeMax time.Duration, tasks []BackgroundTask, dbName string)

Source from the content-addressed store, hash-verified

729
730// waitForBGTCompletion waits for all the background tasks to finish.
731func waitForBGTCompletion(ctx context.Context, waitTimeMax time.Duration, tasks []BackgroundTask, dbName string) {
732 waitTime := waitTimeMax
733 for _, t := range tasks {
734 start := time.Now()
735 select {
736 case <-t.doneChan:
737 waitTime -= time.Now().Sub(start)
738 continue
739 case <-time.After(waitTime):
740 // Timeout after waiting for background task to terminate.
741 }
742 base.InfofCtx(ctx, base.KeyAll, "Timeout after %v of waiting for background task %q to "+
743 "terminate, database: %s", waitTimeMax, t.taskName, dbName)
744 }
745}
746
747func (context *DatabaseContext) IsClosed() bool {
748 context.BucketLock.RLock()

Callers 3

CloseMethod · 0.85
StopMethod · 0.85
StopMethod · 0.85

Calls 2

InfofCtxFunction · 0.92
AfterMethod · 0.80

Tested by

no test coverage detected