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

Method Stop

db/change_cache.go:215–237  ·  view source on GitHub ↗

Stops the cache. Clears its state and tells the housekeeping task to stop.

(ctx context.Context)

Source from the content-addressed store, hash-verified

213
214// Stops the cache. Clears its state and tells the housekeeping task to stop.
215func (c *changeCache) Stop(ctx context.Context) {
216
217 if !c.started.IsTrue() {
218 // changeCache never started - nothing to stop
219 return
220 }
221
222 if !c.stopped.CompareAndSwap(false, true) {
223 base.WarnfCtx(ctx, "changeCache was already stopped")
224 return
225 }
226
227 // Signal to background goroutines that the changeCache has been stopped, so they can exit
228 // their loop
229 close(c.terminator)
230
231 // Wait for changeCache background tasks to finish.
232 waitForBGTCompletion(ctx, BGTCompletionMaxWait, c.backgroundTasks, c.db.Name)
233
234 c.lock.Lock()
235 c.logsDisabled = true
236 c.lock.Unlock()
237}
238
239// Empty out all channel caches.
240func (c *changeCache) Clear(ctx context.Context) error {

Calls 6

WarnfCtxFunction · 0.92
waitForBGTCompletionFunction · 0.85
IsTrueMethod · 0.80
CompareAndSwapMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45