package gojay

import (
	
	
)

var streamDecPool = sync.Pool{
	New: newStreamDecoderPool,
}

// NewDecoder returns a new StreamDecoder.
// It takes an io.Reader implementation as data input.
// It initiates the done channel returned by Done().
func ( stream) ( io.Reader) *StreamDecoder {
	 := NewDecoder()
	 := &StreamDecoder{
		Decoder: ,
		done:    make(chan struct{}, 1),
		mux:     sync.RWMutex{},
	}
	return 
}
func newStreamDecoderPool() interface{} {
	return Stream.NewDecoder(nil)
}

// BorrowDecoder borrows a StreamDecoder from the pool.
// It takes an io.Reader implementation as data input.
// It initiates the done channel returned by Done().
//
// If no StreamEncoder is available in the pool, it returns a fresh one
func ( stream) ( io.Reader) *StreamDecoder {
	return .borrowDecoder(, 512)
}

func ( stream) ( io.Reader,  int) *StreamDecoder {
	 := streamDecPool.Get().(*StreamDecoder)
	.called = 0
	.keysDone = 0
	.cursor = 0
	.err = nil
	.r = 
	.length = 0
	.isPooled = 0
	.done = make(chan struct{}, 1)
	if  > 0 {
		.data = make([]byte, )
	}
	return 
}

// Release sends back a Decoder to the pool.
// If a decoder is used after calling Release
// a panic will be raised with an InvalidUsagePooledDecoderError error.
func ( *StreamDecoder) () {
	.isPooled = 1
	streamDecPool.Put()
}