代码拉取完成,页面将自动刷新
package memqueue
import "github.com/elastic/beats/libbeat/publisher"
type batchBuffer struct {
next *batchBuffer
flushed bool
events []publisher.Event
clients []clientState
}
func newBatchBuffer(sz int) *batchBuffer {
b := &batchBuffer{}
b.init(sz)
return b
}
func (b *batchBuffer) init(sz int) {
b.events = make([]publisher.Event, 0, sz)
b.clients = make([]clientState, 0, sz)
}
func (b *batchBuffer) initWith(sz int, old batchBuffer) {
events, clients := old.events, old.clients
L := len(events)
b.events = make([]publisher.Event, L, sz)
b.clients = make([]clientState, L, sz)
copy(b.events, events)
copy(b.clients, clients)
}
func (b *batchBuffer) add(event publisher.Event, st clientState) {
b.events = append(b.events, event)
b.clients = append(b.clients, st)
}
func (b *batchBuffer) length() int {
return len(b.events)
}
func (b *batchBuffer) capacity() int {
return cap(b.events)
}
func (b *batchBuffer) cancel(st *produceState) int {
events := b.events[:0]
clients := b.clients[:0]
removed := 0
for i := range b.clients {
if b.clients[i].state == st {
removed++
continue
}
events = append(events, b.events[i])
clients = append(clients, b.clients[i])
}
b.events = events
b.clients = clients
return removed
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。