| 1 | package logg |
| 2 | |
| 3 | import "sync" |
| 4 | |
| 5 | var objectPools = &objectPoolsHolder{ |
| 6 | entryPool: &sync.Pool{ |
| 7 | New: func() any { |
| 8 | return &Entry{} |
| 9 | }, |
| 10 | }, |
| 11 | } |
| 12 | |
| 13 | type objectPoolsHolder struct { |
| 14 | // This is only used for the event copy passed to HandleLog. |
| 15 | entryPool *sync.Pool |
| 16 | } |
| 17 | |
| 18 | func (h *objectPoolsHolder) GetEntry() *Entry { |
| 19 | return h.entryPool.Get().(*Entry) |
| 20 | } |
| 21 | |
| 22 | func (h *objectPoolsHolder) PutEntry(e *Entry) { |
| 23 | e.reset() |
| 24 | h.entryPool.Put(e) |
| 25 | } |