Closed ivan-kleshnin closed 8 years ago
I agree. That code is at the top of my "to be refactored" list, once I figure out how to handle it. The issue is that an unbuffered channel should never resolve a put
until a take
is available. In order to handle that with the same code as a buffered channel, the only solutions I could come up with (short of a bunch of if
statements inside _slide()
, which was worse for performance) were these --
puts
, in this case).puts
as the buffer, which also involved a bunch of special code mixed in and dependent from the rest of the buffered slide logic anyways.In the end I opted for finishing off the "make it work" part of "make it work, make it right, make it fast", and I think it's fair to say that's where it still is today. Definitely open to other suggestions. Could be a good use case for a separate class entirely. BufferedChannel
or something. But that's a discussion for a different location. :) Will merge this PR and we can continue discussion elsewhere if necessary.
I've left single commit with code removal here bevause sliding conditions were overcomplicated even in my versions.
In my opinion, you should support only buffered sliding and remove everything else alltogether because those "similar but not exact" parallel code stacks (
_bufferedSlide
vs_slide
...) is a bad sign.And that's obviously not something I can "fix".