MCPcopy
hub / github.com/jackc/pgx / Read

Method Read

pgconn/internal/bgreader/bgreader.go:90–108  ·  view source on GitHub ↗

Read implements the io.Reader interface.

(p []byte)

Source from the content-addressed store, hash-verified

88
89// Read implements the io.Reader interface.
90func (r *BGReader) Read(p []byte) (int, error) {
91 r.cond.L.Lock()
92 defer r.cond.L.Unlock()
93
94 if len(r.readResults) > 0 {
95 return r.readFromReadResults(p)
96 }
97
98 // There are no unread background read results and the background reader is stopped.
99 if r.status == StatusStopped {
100 return r.r.Read(p)
101 }
102
103 // Wait for results from the background reader
104 for len(r.readResults) == 0 {
105 r.cond.Wait()
106 }
107 return r.readFromReadResults(p)
108}
109
110// readBackgroundResults reads a result previously read by the background reader. r.cond.L must be held.
111func (r *BGReader) readFromReadResults(p []byte) (int, error) {

Callers 1

bgReadMethod · 0.45

Calls 1

readFromReadResultsMethod · 0.95

Tested by

no test coverage detected