mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Remove nested locks in treestats collector
This commit is contained in:
parent
95ba16876a
commit
1bf2a994c2
1 changed files with 6 additions and 2 deletions
|
@ -25,9 +25,13 @@ func (t *TreeStatsCollector) Register(tree *syncTree) {
|
|||
|
||||
func (t *TreeStatsCollector) Collect() []TreeStats {
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
stats := make([]TreeStats, 0, len(t.trees))
|
||||
trees := make([]*syncTree, 0, len(t.trees))
|
||||
for _, tree := range t.trees {
|
||||
trees = append(trees, tree)
|
||||
}
|
||||
t.mutex.Unlock()
|
||||
stats := make([]TreeStats, 0, len(t.trees))
|
||||
for _, tree := range trees {
|
||||
tree.Lock()
|
||||
stats = append(stats, TreeStats{
|
||||
TreeLen: tree.Len(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue