brunoV/throttler — pull request #3 by dparis (2014-07-09 03:42:21+00:00)
Title: Fix goroutines in chan-throttler* logic

The two goroutines in `chan-throttler*` were set up to loop infinitely, assuming that the loop would park on the bucket channel put/take operations. Since the bucket channel never closes even if the throttled input channel does, these goroutines will stay parked (and thus not garbage-collected) forever.

I made some minor changes to the looping logic to address this. Now, both loops within the go blocks only occur when the bucket channel is open. Once the throttler input channel is closed, along with closing the output channel, the bucket channel is now closed too. This stops both loops within the go blocks which allows them to return and eventually be cleaned up.

I also replaced the pipe macro invocation, and since it wasn't being called anywhere else, removed the macro. If you'd like, I can put it back.

All of the midje tests pass. If there's further testing you'd like me do, let me know.

Cheers!