mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-02-14 12:15:22 -05:00
refine buffer usage in kcp
This commit is contained in:
@@ -17,12 +17,12 @@ const (
|
||||
// quickly.
|
||||
type Buffer struct {
|
||||
head []byte
|
||||
pool *BufferPool
|
||||
pool Pool
|
||||
Value []byte
|
||||
offset int
|
||||
}
|
||||
|
||||
func CreateBuffer(container []byte, parent *BufferPool) *Buffer {
|
||||
func CreateBuffer(container []byte, parent Pool) *Buffer {
|
||||
b := new(Buffer)
|
||||
b.head = container
|
||||
b.pool = parent
|
||||
|
||||
@@ -4,6 +4,11 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Pool interface {
|
||||
Allocate() *Buffer
|
||||
Free(*Buffer)
|
||||
}
|
||||
|
||||
type BufferPool struct {
|
||||
chain chan []byte
|
||||
allocator *sync.Pool
|
||||
|
||||
Reference in New Issue
Block a user