Files
weave-scope/probe/sync_report.go
2015-11-09 16:25:28 +00:00

27 lines
387 B
Go

package probe
import (
"sync"
"github.com/weaveworks/scope/report"
)
type syncReport struct {
mtx sync.RWMutex
rpt report.Report
}
func (r *syncReport) swap(other report.Report) report.Report {
r.mtx.Lock()
defer r.mtx.Unlock()
old := r.rpt
r.rpt = other
return old
}
func (r *syncReport) copy() report.Report {
r.mtx.RLock()
defer r.mtx.RUnlock()
return r.rpt.Copy()
}