Source File
encode_stream_pool.go
Belonging Package
github.com/francoispqt/gojay
package gojayimport ()// NewEncoder returns a new StreamEncoder.// It takes an io.Writer implementation to output data.// It initiates the done channel returned by Done().func ( stream) ( io.Writer) *StreamEncoder {:= BorrowEncoder()return &StreamEncoder{Encoder: , nConsumer: 1, done: make(chan struct{}, 1), mux: &sync.RWMutex{}}}// BorrowEncoder borrows a StreamEncoder from the pool.// It takes an io.Writer implementation to output data.// It initiates the done channel returned by Done().//// If no StreamEncoder is available in the pool, it returns a fresh onefunc ( stream) ( io.Writer) *StreamEncoder {:= streamEncPool.Get().(*StreamEncoder).w =.Encoder.err = nil.done = make(chan struct{}, 1).Encoder.buf = .buf[:0].nConsumer = 1.isPooled = 0return}func ( stream) ( io.Writer) *StreamEncoder {:= streamEncPool.Get().(*StreamEncoder).isPooled = 0.w =.Encoder.err = nilreturn}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |