Proposal: extract raw Ring Buffer structure out of channels module
While doing refactoring of channels (#21), I've separated all the raw ring/circular buffer logic into it's own object and put it in a module. I think this could prove useful:
- Separation of concern => more succinct, easily readable and testable code.
- Current channel implementation just adds locking around enqueue/dequeue ops and fullness checks, so there's nothing invasive which could prevent separation.
- Having a separate module for a basic data structure could provide a basis for a public-facing typed version easily (the only real work necessary is a JS version, which can't use any raw memory ops).
I can start with just having a separate object in the same module, and if this channel implementation stabilizes, it can be moved out and open the ways of using the basic data structure in other places.
Ok, go for it.
@ZoomRmc did you ever end up doing this? It'd be handy. I modified channel to support overwrite operation in the ring buffer, but it'd be nice to be able to swap out the ring-buffer logic or otherwise tweak it.
@ZoomRmc did you ever end up doing this?
I had worked something out in a private repo, but as I recall the current channels implementation prevents reusing a generic ringbuffer so I didn't pursue merging in the basic data structure further.
IIRC the issue is that channels here try to do do many things at once so have a bit of branching inside basic operations. I didn't close the issue as I still think it could be beneficial and also wasn't sure how long the current channels' impl stays unchanged.