Revert "attempt copying slice"

This reverts commit 0d4d40513fccd31b9cdc4db369aa87e87c529be4.
This commit is contained in:
Hector Sanjuan 2019-03-21 14:39:35 +01:00 committed by Adrian Lanzafame
parent 46d6cb155d
commit da3c543ce2
No known key found for this signature in database
GPG Key ID: 87E40C5D62EAE192

View File

@ -74,7 +74,9 @@ func (mw *Window) All() []*api.Metric {
mw.wMu.Lock()
// get to position so window.Do starts on the correct value
mw.window = mw.window.Next()
mw.wMu.Unlock()
mw.wMu.RLock()
values := make([]*api.Metric, 0, mw.window.Len())
mw.window.Do(func(v interface{}) {
if i, ok := v.(*api.Metric); ok {
@ -82,11 +84,8 @@ func (mw *Window) All() []*api.Metric {
values = append([]*api.Metric{i}, values...)
}
})
mw.window = mw.window.Prev()
mw.wMu.Unlock()
copyValues := make([]*api.Metric, len(values))
copy(copyValues, values)
return copyValues
mw.wMu.RUnlock()
return values
}
// Distribution returns the deltas between all the current