On Fri, Nov 13, 2020 at 8:12 AM 陶青云 <qingyu...@gmail.com> wrote:
> > It is not a one-length buffered channel. I need to drop because the > recveiver do heavy work that can't process as quickly as sender. > You need to write a flow control scheme then. Channels may be part of the solution, but they can't solve it on their own. If the receiver can periodically stop work and check on the channel, a relatively simple way is to record queue sojourn: add a timestamp at send time, and call time.Since upon pulling it out of the queue. The duration in the queue is the sojourn time, and you can use that to error out on work that has spent too long in the queue. If this happens inside the same goroutine, just use a standard queue, or perhaps a ring buffer though memory eludes me if the stdlib ring is useful for this case. -- 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/CAGrdgiVYaEu5VLVaF6MAe-7Z9e8zkuV%3D_EGkONBD7jf1NUYoKw%40mail.gmail.com.