lockfree icon indicating copy to clipboard operation
lockfree copied to clipboard

Added a Clear method that resets the read and write indexes.

Open perencia-wc opened this issue 1 year ago • 3 comments

perencia-wc avatar Apr 10 '24 10:04 perencia-wc

Thanks for the contribution! One issue with adding a Clear() method like this is that it is not thread safe.

We can solve this by either:

  1. Adding a note to the javadoc comment
  2. Creating separate ClearFromConsumer(), ClearFromProducer() methods

I am not a fan of either approach tbh, as you can also create a new Ring Buffer over the old one. On the other hand I also want the library to be convenient for the people actually using it, so we can go with either of these.

DNedic avatar Apr 10 '24 11:04 DNedic

Thanks for the contribution! One issue with adding a Clear() method like this is that it is not thread safe.

We can solve this by either:

  1. Adding a note to the javadoc comment
  2. Creating separate ClearFromConsumer(), ClearFromProducer() methods

perencia-wc avatar Apr 10 '24 16:04 perencia-wc

I would preffer for the PR to stay open for a while to have time to perhaps get comments from more users, and for me to think about this some more.

DNedic avatar Apr 13 '24 20:04 DNedic