mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2026-08-22 19:43:28 +08:00
add helper method to release all buffers
This commit is contained in:
7
scope.go
7
scope.go
@@ -33,6 +33,13 @@ func (rc *ResourceScope) checkMemory(rsvp int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rc *ResourceScope) releaseBuffers() {
|
||||
for key, buf := range rc.buffers {
|
||||
pool.Put(buf)
|
||||
delete(rc.buffers, key)
|
||||
}
|
||||
}
|
||||
|
||||
func (rc *ResourceScope) ReserveMemory(size int) error {
|
||||
rc.Lock()
|
||||
defer rc.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user