Documentation
¶
Overview ¶
Package decoderhandle provides a small fixed-size pool of long-lived decoder.Decoder instances. Replaces the fac.New() / dec.Close() per-tile pattern with Borrow/Return, eliminating per-tile tjInit + tjDestroy churn (~290 µs/call dominated by tjDestroy).
Concurrency: Borrow blocks when all pool members are in use; Return is non-blocking. Pool members are not concurrent-safe (libjpeg-turbo tjhandle is single-threaded), so Borrow grants exclusive access for the lifetime of the borrow.
Lifetime: members are lazy-initialised on first Borrow. Close drains the pool and tears down every member. After Close, Borrow returns ErrClosed; Return on a closed pool tears the member down directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("decoderhandle: pool closed")
ErrClosed is returned by Borrow if Close has been called.
var ErrFactoryReturnedNil = errors.New("decoderhandle: factory.New() returned nil")
ErrFactoryReturnedNil is returned by Borrow if factory.New() returned nil. Surfaces what would otherwise be a nil-decoder panic in Decode.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a fixed-size pool of decoder.Decoder instances.
func New ¶
New constructs a pool of capacity members for the given factory. capacity must be > 0; smaller values are clamped to 1. Members are NOT created up-front; the first Borrow that needs to grow the pool invokes factory.New().
func (*Pool) Borrow ¶
Borrow acquires a Decoder. Blocks if all members are in use AND the pool is at capacity. Returns ErrClosed if Close has been called. Caller must call Return when done.