dvlsg / async-csp

CSP style channels using ES7 async/await
MIT License
317 stars 18 forks source link

refactor: remove excessive code from channel implementation #11

Closed ivan-kleshnin closed 8 years ago

ivan-kleshnin commented 8 years ago

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".

dvlsg commented 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 --

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.