github.com/zartbot/goflow@v0.0.0-20221001080520-456f7dfad288/datarecord/syncpool.go (about) 1 package datarecord 2 3 import "sync" 4 5 var DATAFRAME_SYNC_POOL *sync.Pool 6 7 func init() { 8 DATAFRAME_SYNC_POOL = &sync.Pool{New: func() interface{} { 9 return &DataFrame{ 10 AgentID: "", 11 DomainID: 0, 12 ExportTime: 0, 13 SetID: 0, 14 Type: "", 15 Record: make([]map[string]interface{}, 0, 1), 16 } 17 }} 18 } 19 20 func NewDataFrame() *DataFrame { 21 v := DATAFRAME_SYNC_POOL.Get().(*DataFrame) 22 return v 23 } 24 25 func Free(d *DataFrame) { 26 DATAFRAME_SYNC_POOL.Put(d) 27 }