WithDecoderConcurrency sets the number of created decoders. When decoding block with DecodeAll, this will limit the number of possible concurrently running decodes. When decoding streams, this will limit the number of inflight blocks. When decoding streams and setting maximum to 1, no async decoding
(n int)
| 66 | // By default this will be set to 4 or GOMAXPROCS, whatever is lower. |
| 67 | // Cannot be changed with ResetWithOptions. |
| 68 | func WithDecoderConcurrency(n int) DOption { |
| 69 | return func(o *decoderOptions) error { |
| 70 | if n < 0 { |
| 71 | return errors.New("concurrency must be at least 0") |
| 72 | } |
| 73 | newVal := n |
| 74 | if n == 0 { |
| 75 | newVal = runtime.GOMAXPROCS(0) |
| 76 | } |
| 77 | if o.resetOpt && newVal != o.concurrent { |
| 78 | return errors.New("WithDecoderConcurrency cannot be changed on Reset") |
| 79 | } |
| 80 | o.concurrent = newVal |
| 81 | return nil |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // WithDecoderMaxMemory allows to set a maximum decoded size for in-memory |
| 86 | // non-streaming operations or maximum window size for streaming operations. |
no outgoing calls
searching dependent graphs…