On Thu, 29 Apr 2021, at 3:09 PM, robert engels wrote: > I will give you the pseudo code: > > { // step #1 do select on both > select high > select low > } > > if high read: > return high > else: > // we read a low so do a high poll > { > select high: > default: > } > > if high read: > enqueue low and return high > else: > if queue empty: > return low > else: > use queue and enqueue low from step #1 // FIFO order on low reads > > The above code will always return high values over low values (if high > available), and return low values in order of events
This seems likely deadlock if the low channel is being filled continually by another goroutine. In addition I usually aim to give ownership of the channel to the writer so it can close cleanly, but mixing reads and writes in a single function greatly complicates that. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f26ee7f2-a518-433f-89d4-d55aa0a9b07d%40www.fastmail.com.