Next polls the diode until data is available or until the context is done. If the context is done, then nil will be returned.
()
| 56 | // Next polls the diode until data is available or until the context is done. |
| 57 | // If the context is done, then nil will be returned. |
| 58 | func (p *Poller) Next() GenericDataType { |
| 59 | for { |
| 60 | data, ok := p.Diode.TryNext() |
| 61 | if !ok { |
| 62 | if p.isDone() { |
| 63 | return nil |
| 64 | } |
| 65 | |
| 66 | time.Sleep(p.interval) |
| 67 | continue |
| 68 | } |
| 69 | return data |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func (p *Poller) isDone() bool { |
| 74 | select { |