How to throttle a producer in a producer/consumer situation on a TChan in Haskell?
问题 We have something dumping values on a TChan, and then a consumer processing those. But the consumer can't keep up, so we're getting lots of memory usage as the producer is dumping lots of stuff on the channel, but consumer isn't keeping up. Is there a straightforward way to have the producer block if the channel queue becomes a certain size or something so we can have the producer wait for the consumer to catch up? 回答1: Like John's answer, I'd suggest just building a bounded TChan yourself.