| 105 | } |
| 106 | |
| 107 | type pipe struct { |
| 108 | mu sync.Mutex |
| 109 | |
| 110 | // buf contains the data in the pipe. It is a ring buffer of fixed capacity, |
| 111 | // with r and w pointing to the offset to read and write, respectively. |
| 112 | // |
| 113 | // Data is read between [r, w) and written to [w, r), wrapping around the end |
| 114 | // of the slice if necessary. |
| 115 | // |
| 116 | // The buffer is empty if r == len(buf), otherwise if r == w, it is full. |
| 117 | // |
| 118 | // w and r are always in the range [0, cap(buf)) and [0, len(buf)]. |
| 119 | buf []byte |
| 120 | w, r int |
| 121 | |
| 122 | wwait sync.Cond |
| 123 | rwait sync.Cond |
| 124 | |
| 125 | // Indicate that a write/read timeout has occurred |
| 126 | wtimedout bool |
| 127 | rtimedout bool |
| 128 | |
| 129 | wtimer *time.Timer |
| 130 | rtimer *time.Timer |
| 131 | |
| 132 | closed bool |
| 133 | writeClosed bool |
| 134 | } |
| 135 | |
| 136 | func newPipe(sz int) *pipe { |
| 137 | p := &pipe{buf: make([]byte, 0, sz)} |
nothing calls this directly
no outgoing calls
no test coverage detected