committed by
Jakob Borg
parent
f35e1ac0c5
commit
ceea5ebeb3
14
vendor/github.com/xtaci/kcp-go/emitter.go
generated
vendored
14
vendor/github.com/xtaci/kcp-go/emitter.go
generated
vendored
@@ -7,17 +7,17 @@ import (
|
||||
|
||||
var defaultEmitter Emitter
|
||||
|
||||
const emitQueue = 8192
|
||||
|
||||
func init() {
|
||||
defaultEmitter.init()
|
||||
}
|
||||
|
||||
type (
|
||||
// packet emit request
|
||||
emitPacket struct {
|
||||
conn net.PacketConn
|
||||
to net.Addr
|
||||
data []byte
|
||||
conn net.PacketConn
|
||||
to net.Addr
|
||||
data []byte
|
||||
// mark this packet should recycle to global xmitBuf
|
||||
recycle bool
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ type (
|
||||
)
|
||||
|
||||
func (e *Emitter) init() {
|
||||
e.ch = make(chan emitPacket, emitQueue)
|
||||
e.ch = make(chan emitPacket)
|
||||
go e.emitTask()
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func (e *Emitter) init() {
|
||||
func (e *Emitter) emitTask() {
|
||||
for p := range e.ch {
|
||||
if n, err := p.conn.WriteTo(p.data, p.to); err == nil {
|
||||
atomic.AddUint64(&DefaultSnmp.OutSegs, 1)
|
||||
atomic.AddUint64(&DefaultSnmp.OutPkts, 1)
|
||||
atomic.AddUint64(&DefaultSnmp.OutBytes, uint64(n))
|
||||
}
|
||||
if p.recycle {
|
||||
|
||||
Reference in New Issue
Block a user