()
| 23 | } |
| 24 | |
| 25 | func (r *RingReader[T, F]) TryRead() (f F, err error) { |
| 26 | if r.Count > 0 { |
| 27 | preValue := r.Value |
| 28 | if preValue.IsDiscarded() { |
| 29 | preValue.ReaderLeave() |
| 30 | err = ErrDiscard |
| 31 | return |
| 32 | } |
| 33 | if !r.Next().Value.ReaderTryEnter() { |
| 34 | return |
| 35 | } |
| 36 | r.Ring = r.Next() |
| 37 | } else { |
| 38 | if !r.Value.ReaderTryEnter() { |
| 39 | return |
| 40 | } |
| 41 | } |
| 42 | if r.Value.IsDiscarded() { |
| 43 | err = ErrDiscard |
| 44 | return |
| 45 | } |
| 46 | r.Count++ |
| 47 | f = r.Value |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | func (r *RingReader[T, F]) StopRead() { |
| 52 | if r.locked { |
nothing calls this directly
no test coverage detected