Close closes the stream, preventing the program from reading any more messages from it.
()
| 755 | // Close closes the stream, preventing the program from reading any more |
| 756 | // messages from it. |
| 757 | func (r *Reader) Close() error { |
| 758 | atomic.StoreUint32(&r.once, 1) |
| 759 | |
| 760 | r.mutex.Lock() |
| 761 | closed := r.closed |
| 762 | r.closed = true |
| 763 | r.mutex.Unlock() |
| 764 | |
| 765 | r.cancel() |
| 766 | r.stop() |
| 767 | r.join.Wait() |
| 768 | |
| 769 | if r.done != nil { |
| 770 | <-r.done |
| 771 | } |
| 772 | |
| 773 | if !closed { |
| 774 | close(r.msgs) |
| 775 | } |
| 776 | |
| 777 | return nil |
| 778 | } |
| 779 | |
| 780 | // ReadMessage reads and return the next message from the r. The method call |
| 781 | // blocks until a message becomes available, or an error occurs. The program |
no outgoing calls