fix remove pieces

This commit is contained in:
yourok
2019-10-11 12:17:46 +03:00
parent e36fc05f0a
commit 358de66eff
3 changed files with 30 additions and 25 deletions

View File

@@ -90,21 +90,21 @@ func (b *BufferPool) ReleaseBuffer(index int) {
}
}
func (b *BufferPool) Used() map[int]struct{} {
b.mu.Lock()
defer b.mu.Unlock()
if len(b.buffs) == 0 {
b.mkBuffs()
}
used := make(map[int]struct{})
for _, b := range b.buffs {
if b.used {
used[b.pieceId] = struct{}{}
}
}
return used
}
func (b *BufferPool) Len() int {
return b.frees
}
//func (b *BufferPool) Used() map[int]struct{} {
// b.mu.Lock()
// defer b.mu.Unlock()
// if len(b.buffs) == 0 {
// b.mkBuffs()
// }
// used := make(map[int]struct{})
// for _, b := range b.buffs {
// if b.used {
// used[b.pieceId] = struct{}{}
// }
// }
// return used
//}
//
//func (b *BufferPool) Len() int {
// return b.frees
//}