github.com/hsfzxjy/dgo/go@v0.2.0/pin/pcop/op.go (about) 1 package pcop 2 3 import ( 4 "sync" 5 "unsafe" 6 ) 7 8 type OpKind uint8 9 10 const ( 11 CHAN_LISTEN OpKind = iota 12 CHAN_CANCEL_LISTEN 13 TOKEN_DISPOSE 14 META_DETACHED 15 ) 16 17 type Op struct { 18 Kind OpKind 19 Chid uint8 20 Lid uint8 21 Dcb uint32 22 Port unsafe.Pointer 23 } 24 25 var opchanPool = sync.Pool{ 26 New: func() any { return make(chan Op, 1) }, 27 } 28 29 func NewOpChan() chan Op { return opchanPool.Get().(chan Op) } 30 func RecycleOpChan(ch chan Op) { opchanPool.Put(ch) }