mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-27 04:25:44 -05:00
Use Buffer as a writer
This commit is contained in:
@@ -50,6 +50,11 @@ func (b *Buffer) IsFull() bool {
|
||||
return len(b.Value) == cap(b.Value)
|
||||
}
|
||||
|
||||
func (b *Buffer) Write(data []byte) (int, error) {
|
||||
b.Append(data)
|
||||
return len(data), nil
|
||||
}
|
||||
|
||||
type bufferPool struct {
|
||||
chain chan []byte
|
||||
bufferSize int
|
||||
@@ -98,7 +103,10 @@ func (p *bufferPool) cleanup(tick <-chan time.Time) {
|
||||
continue
|
||||
}
|
||||
for delta := p.buffers2Keep - pSize; delta > 0; delta-- {
|
||||
p.chain <- make([]byte, p.bufferSize)
|
||||
select {
|
||||
case p.chain <- make([]byte, p.bufferSize):
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user