Source File
pool.go
Belonging Package
github.com/valyala/fastjson
package fastjson
import (
)
// ParserPool may be used for pooling Parsers for similarly typed JSONs.
type ParserPool struct {
pool sync.Pool
}
// Get returns a Parser from pp.
//
// The Parser must be Put to pp after use.
func ( *ParserPool) () *Parser {
:= .pool.Get()
if == nil {
return &Parser{}
}
return .(*Parser)
}
// Put returns p to pp.
//
// p and objects recursively returned from p cannot be used after p
// is put into pp.
func ( *ParserPool) ( *Parser) {
.pool.Put()
}
// ArenaPool may be used for pooling Arenas for similarly typed JSONs.
type ArenaPool struct {
pool sync.Pool
}
// Get returns an Arena from ap.
//
// The Arena must be Put to ap after use.
func ( *ArenaPool) () *Arena {
:= .pool.Get()
if == nil {
return &Arena{}
}
return .(*Arena)
}
// Put returns a to ap.
//
// a and objects created by a cannot be used after a is put into ap.
func ( *ArenaPool) ( *Arena) {
.pool.Put()
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)