MCPcopy Create free account
hub / github.com/facebook/time / Drain

Method Drain

sa53/protocol/protocol.go:123–135  ·  view source on GitHub ↗

Drain consumes pending bytes on the port without blocking, then restores the normal read timeout. Call before Cmd / Get to clear stale or asynchronous bytes left over from a previous interaction.

()

Source from the content-addressed store, hash-verified

121// the normal read timeout. Call before Cmd / Get to clear stale or
122// asynchronous bytes left over from a previous interaction.
123func (m *Mac) Drain() {
124 if err := m.port.SetReadTimeout(drainReadTimeout); err != nil {
125 return
126 }
127 defer func() { _ = m.port.SetReadTimeout(normalReadTimeout) }()
128 tmp := make([]byte, 256)
129 for {
130 n, err := m.port.Read(tmp)
131 if err != nil || n == 0 {
132 return
133 }
134 }
135}
136
137// ReadResponse reads from the port until it sees a "\r\n" terminator or a
138// read error. Returns the response without the terminator. A read that

Callers 4

CmdMethod · 0.95
runPollFunction · 0.45
pollOnceFunction · 0.45

Calls 2

SetReadTimeoutMethod · 0.65
ReadMethod · 0.65

Tested by 1