MCPcopy Create free account
hub / github.com/docker/cli / snapshot

Method snapshot

cli/command/container/stats_helpers.go:56–66  ·  view source on GitHub ↗

snapshot returns a point-in-time copy of the tracked container list (the slice of *Stats pointers). The returned slice is safe for use without holding the stats lock, but the underlying Stats values may continue to change concurrently.

()

Source from the content-addressed store, hash-verified

54// without holding the stats lock, but the underlying Stats values may
55// continue to change concurrently.
56func (s *stats) snapshot() []*Stats {
57 s.mu.RLock()
58 defer s.mu.RUnlock()
59 if len(s.cs) == 0 {
60 return nil
61 }
62 // https://github.com/golang/go/issues/53643
63 cp := make([]*Stats, len(s.cs))
64 copy(cp, s.cs)
65 return cp
66}
67
68func collect(ctx context.Context, s *Stats, cli client.ContainerAPIClient, streamStats bool, waitFirst *sync.WaitGroup) { //nolint:gocyclo
69 var getFirst bool

Callers 1

RunStatsFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected