Start starts the backgrounder reader. If the background reader is already running this is a no-op. The background reader will stop automatically when the underlying reader returns an error.
()
| 31 | // Start starts the backgrounder reader. If the background reader is already running this is a no-op. The background |
| 32 | // reader will stop automatically when the underlying reader returns an error. |
| 33 | func (r *BGReader) Start() { |
| 34 | r.cond.L.Lock() |
| 35 | defer r.cond.L.Unlock() |
| 36 | |
| 37 | switch r.status { |
| 38 | case StatusStopped: |
| 39 | r.status = StatusRunning |
| 40 | go r.bgRead() |
| 41 | case StatusRunning: |
| 42 | // no-op |
| 43 | case StatusStopping: |
| 44 | r.status = StatusRunning |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // Stop tells the background reader to stop after the in progress Read returns. It is safe to call Stop when the |
| 49 | // background reader is not running. |