mirror of
https://github.com/lkmio/lkm.git
synced 2025-10-23 23:23:14 +08:00
重构缓存
This commit is contained in:
@@ -31,6 +31,8 @@ type MemoryPool interface {
|
||||
FreeTail()
|
||||
|
||||
Data() ([]byte, []byte)
|
||||
|
||||
Clear()
|
||||
}
|
||||
|
||||
func NewMemoryPool(capacity int) MemoryPool {
|
||||
@@ -177,3 +179,14 @@ func (m *memoryPool) Data() ([]byte, []byte) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (m *memoryPool) Clear() {
|
||||
m.capacity = cap(m.data)
|
||||
m.head = 0
|
||||
m.tail = 0
|
||||
|
||||
m.markIndex = 0
|
||||
m.mark = false
|
||||
|
||||
m.blockQueue.Clear()
|
||||
}
|
||||
|
Reference in New Issue
Block a user