Terminate waits for in-progress Read calls, if any, to finish, and ensures that after this function returns, any Read calls will fail with the provided error, and the underlying reader will never be used any more. It is safe to call this from a different goroutine than Read.
(err error)
| 54 | // |
| 55 | // It is safe to call this from a different goroutine than Read. |
| 56 | func (ur *UploadReader) Terminate(err error) { |
| 57 | ur.mutex.Lock() // May block for some time if ur.reader.Read() is in progress |
| 58 | defer ur.mutex.Unlock() |
| 59 | |
| 60 | ur.terminationError = err |
| 61 | } |
no outgoing calls