(parentWriter io.Writer, level int)
| 49 | } |
| 50 | |
| 51 | func (this *WriterPool) Get(parentWriter io.Writer, level int) (Writer, error) { |
| 52 | if isBusy { |
| 53 | return nil, ErrIsBusy |
| 54 | } |
| 55 | |
| 56 | select { |
| 57 | case writer := <-this.c: |
| 58 | writer.Reset(parentWriter) |
| 59 | writer.ResetFinish() |
| 60 | return writer, nil |
| 61 | default: |
| 62 | writer, err := this.newFunc(parentWriter, level) |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | writer.SetPool(this) |
| 67 | return writer, nil |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | func (this *WriterPool) Put(writer Writer) { |
| 72 | if writer.IncreaseHit() > maxWriterHits { |
no test coverage detected