Close will release all resources. It is NOT possible to reuse the decoder after this.
()
| 579 | // Close will release all resources. |
| 580 | // It is NOT possible to reuse the decoder after this. |
| 581 | func (d *Decoder) Close() { |
| 582 | if d.current.err == ErrDecoderClosed { |
| 583 | return |
| 584 | } |
| 585 | d.drainOutput() |
| 586 | if d.current.cancel != nil { |
| 587 | d.current.cancel() |
| 588 | d.streamWg.Wait() |
| 589 | d.current.cancel = nil |
| 590 | } |
| 591 | if d.decoders != nil { |
| 592 | close(d.decoders) |
| 593 | for dec := range d.decoders { |
| 594 | dec.Close() |
| 595 | } |
| 596 | d.decoders = nil |
| 597 | } |
| 598 | if d.current.d != nil { |
| 599 | d.current.d.Close() |
| 600 | d.current.d = nil |
| 601 | } |
| 602 | d.current.err = ErrDecoderClosed |
| 603 | } |
| 604 | |
| 605 | // IOReadCloser returns the decoder as an io.ReadCloser for convenience. |
| 606 | // Any changes to the decoder will be reflected, so the returned ReadCloser |