GetParser returns a Parser instance from the pool. The caller MUST call PutParser when done to return it to the pool. This function is thread-safe and designed for concurrent use. Each goroutine should get its own parser instance from the pool. Performance: O(1) amortized, <50ns typical latency U
()
| 84 | // |
| 85 | // Thread Safety: Safe for concurrent calls - each goroutine gets its own instance. |
| 86 | func GetParser() *Parser { |
| 87 | metrics.RecordNamedPoolGet("parser") |
| 88 | return parserPool.Get().(*Parser) |
| 89 | } |
| 90 | |
| 91 | // PutParser returns a Parser instance to the pool after resetting it. |
| 92 | // This MUST be called after parsing is complete to enable reuse and prevent memory leaks. |